Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

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

Asked by
JoneXI 56
1 month ago
Edited 1 month 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 113 — 1mo

2 answers

Log in to vote
0
Answered by 1 month 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 1 month ago
Edited 1 month 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