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

Does anyone know why this script to reduce an IntValue every second isn’t working?

Asked by 4 years ago

So, I made this script that is supposed to take the value of an int value, and remove one from it every second for 15 seconds. I’m not exactly sure why it’s not working. If you need any additional info I’d be happy to provide it. Thank you so much for your time!

Script:


while game.ServerStorage.DropTimerRepeater.Value >= 1 do game.ServerStorage.DropTimerRepeater.Value = game.ServerStorage.DropTimerRepeater.Value - 1 game.ServerStorage.TimeUntilDrop.Value = game.ServerStorage.TimeUntilDrop.Value - 1 wait(1) end if game.ServerStorage.TimeUntilDrop == 0 then game.Workspace.Part2.SurfaceGui.TextLabel.Text = ("Bye, bye! >:D") wait(1) game.Workspace.DropPart.Anchored = false game.Workspace.Part1:Destroy() game.Workspace.Part2:Destroy() game.Workspace.Part3:Destroy() game.Workspace.Part4:Destroy() game.Workspace.Top:Destroy() wait(10) game.Workspace.DropPart.Transparency = 0.5 wait(0.5) game.Workspace.DropPart.Transparency = 0.7 wait(0.5) game.Workspace.DropPart.Transparency = 0.9 wait(1) game.Workspace.DropPart:Destroy() end

1 answer

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

Try a for loop.

for i = 15,0,-1 do
    if i == 0 then  
        game.Workspace.Part2.SurfaceGui.TextLabel.Text = ("Bye, bye! >:D") wait(1) 
                game.Workspace.DropPart.Anchored = false game.Workspace.Part1:Destroy() 
                game.Workspace.Part2:Destroy() game.Workspace.Part3:Destroy() 
                game.Workspace.Part4:Destroy() game.Workspace.Top:Destroy() wait(10) 
                game.Workspace.DropPart.Transparency = 0.5 wait(0.5) 
                game.Workspace.DropPart.Transparency = 0.7 wait(0.5) 
                game.Workspace.DropPart.Transparency = 0.9 wait(1) 
                game.Workspace.DropPart:Destroy()
wait(1)
end

i is the current value, 15 is the starting number, 0 is the ending number, and -1 is the increment. It counts down each second because of the wait(1). It'll run the loop 15 times, and when i reached zero, the if statement will run the code within it. I am still new to coding, so if this doesn't work let me know and we'll figure it out together.

0
Thank you so much! Sorry I didn't see this until now. This worked very well, thank you so much for actually putting in the effort to rewrite the script for me. :D lincol92008 46 — 4y
Ad

Answer this question