I am trying to make a cash script, for every minute you get 10 cash but the problem is I tried something like this ;

game.Players.PlayerAdded:connect(function(player)
local folder = Instance.new("Folder", player)
folder.Name = "leaderstats"
local val = Instance.new("NumberValue", folder)
val.Name = "Cash"
while true do
	wait(60)
	val.Value = val.Value + 10
end
end)

(if the above script doesn't work, I just wrote it quickly (on iPhone), it's just an example of my real code)

The problem with this is that it increases the speed of the loop every time a player joins the game, such as if I had a variable "i = 1" and put "i = i + 1" inside the loop it would go faster and faster everytime a player joined.

I don't know how to bypass this, by the way FilterningEnabled is ON.

3 comments

0

What do you mean by it would go faster & faster every time a player joins? :P

0

Apparently every time a player joins a new loop starts, since I don't have a loop for a specific player.

0

Obviously your issue is that you put the while true do loop inside of the playerAdded event.