Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
JoneXI 51
4 years ago
Edited 4 years ago

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!

0
Maybe try to debug with prints and see what happens. nievadev 112 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago

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.

Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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

Answer this question