Hi, I have a reward system with a cooldown. The cooldown (seconds left) is a value. I tried to make a script that decreases all of the values by 1 every second, but it is not working. Look at the following script.
Cooldowns is a folder with all the cooldown values in it.
I tried adding a print after the for statement but it didn’t print if that helps.
Thanks
the player could join before the .PlayerAdded is connected. Try this
function playeradded(player)
for i,v in pairs(player:WaitForChild("Cooldowns"):GetChildren()) do
v.Value -= 1
wait(1)
end
end
game.Players.PlayerAdded:Connect(playeradded)
for _,v in pairs(game.Players:GetPlayers()) do
playeradded(v)
end
1 Like
Assuming that you want each player’s cooldown value decrease infinitely, you would probably want to use an infinite while loop. Something like this:
while task.wait(1) do
for i, player in pairs (game.Players:GetChildren()) do
for j, cooldown in pairs (player:WaitForChild("Cooldowns"):GetChildren()) do
cooldown.Value -= 1
end
end
end
However, this code still feels incorrect. Are you sure that each player has multiple cooldowns?
There will be multiple cooldowns but its going below 0
not working
aaaaaaaaaaaaaaaaaaaaaaaaa