Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I make that the value would go down by 1 every second?

Hello, how do I make that the value would go down by 1 every second?

Script:

while can.Value == true do wait(1)
	if player:FindFirstChild("Cooldowns") then
		if player.Cooldowns.A1.Value > 0 then
			player.Cooldowns.A1.Value = player.Cooldowns.A1.Value - 1
	end
		if player.Cooldowns.A2.Value > 0 then
			player.Cooldowns.A2.Value = player.Cooldowns.A2.Value - 1
		end
	end	
end

This scirpt sometimes works and sometimes it doesn't, i dont know why... Maybe there is another way around this?

Also, I do not get any errors.

Any help would be appreciated!

1 comment

0

Maybe try to debug with prints and see what happens.

2 answers

If Can.Value changes to false the script will stop and that entire part will not happen again at all, so put the while loop inside of another while true loop and then when the while can == true loop end it will wait until can is equal to true.

Try this:

while can.Value == true do wait(1)
    if player:FindFirstChild("Cooldowns") then
	if player.Cooldowns.A1.Value > 0 and player.Cooldowns.A2.Value > 0 then
			player.Cooldowns.A1.Value = player.Cooldowns.A1.Value - 1					 																																					 
 			player.Cooldowns.A2.Value = player.Cooldowns.A2.Value - 1
		end
	end
end

This discussion is preserved as it was. New answers, comments, and votes are closed.