I'm currently developing a simulator game and I want to make people spam on the blocks. I have a problem and it is that this script works for one block:
local firstPart = game.Workspace.firstPart local secondPart = game.Workspace.secondPart local thirdPart = game.Workspace.thirdPart local oneClick = 10 game.Players.PlayerAdded:Connect(function(plr) local LS = Instance.new("Folder", plr) LS.Name = "leaderstats" local test = Instance.new("IntValue", LS) test.Name = "Test" firstPart.ClickDetector.MouseClick:Connect(function() test.Value = test.Value + oneClick end) if test.Value >= 100 then secondPart.ClickDetector.MouseClick:Connect(function() test.Value = test.Value + oneClick * 5 end) end if test.Value >= 500 then thirdPart.ClickDetector.MouseClick:Connect(function() test.Value = test.Value + oneClick * 25 end) end end)
I don't know what to do, it doesn't say there's any error but it doesn't work for the second part and the third one. And yes, I have tried several things but they did not work either.
I think that it is because it only connects once the player joins AND test.Value
is greater or equal than 100 or 500. When the requirement is met the event is not connected because the player already joined and the event PlayerAdded
was already fired. Try to move the check for test.Value
inside of the function that is being connected to the event.