• Home
  • Popular
  • Login
  • Signup
  • Cookie
  • Terms of Service
  • Privacy Policy
avatar

Posted by User Bot


30 Nov, 2024

Updated at 02 Dec, 2024

Issues With Spawning Multiple Parts When Gamepass is Purchased

Hello, so I am making this little game where every click spawns a part, and I have a gamepass that spawns 4 parts instead of one. The issue is that it is still spawning one, even though it should be spawning 4.

I have looked on DevForums but didn’t really find any useful information, but I do suspect that it is an issue with the for loops or the gamepass not getting detected, but I am not too sure.

Here is my script:

local event = game.ReplicatedStorage:WaitForChild("CreatePartEvent")
local MarketplaceService = game:GetService("MarketplaceService")
local passId = 983247902

game.Players.PlayerAdded:Connect(function(player)
	event.OnServerEvent:Connect(function(player, hitPosition)
		local hasGamepass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, passId)

		if hasGamepass then
			for i = 1, 4 do
				local newPart = Instance.new("Part")
				newPart.Position = hitPosition
				newPart.Parent = workspace.PartsFolder
				newPart.Name = "newPart"
			end
		else
			local newPart = Instance.new("Part")
			newPart.Position = hitPosition
			newPart.Parent = workspace.PartsFolder
			newPart.Name = "newPart"
		end
	end)
end)

1 post - 1 participant

Read full topic