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

i have a timer made but i want to make it so when it hits 0 it resets?

Asked by 3 years ago

here is my script its a local script (local seconds = script.Parent.Parent.Time script.Parent.Text = seconds.Value for i = 1,seconds.Value do wait(1) seconds.Value = seconds.Value - 1 script.Parent.Text = seconds.Value end )

4 answers

Log in to vote
0
Answered by 3 years ago

Format your code using the blue lua button when writing it on this forum :)

It makes this much easier to read so we can help you!
0
im new to this site so i never new thanks for the help ! Chaotic_Devel0per 7 — 3y
Ad
Log in to vote
0
Answered by 3 years ago

i agree with the other guy, please format the code so that it isnt confusing. Anyways heres the script:

while wait() do
      wait(0.1)
      if seconds.Value == 0 then
             wait(1)
             seconds.Value = --Put the number you want here
      end
end
Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

lets say you want to make a timer, make a variable first

local Timer = 60 -- you can make it anything

now you want to do the actual script that does the timer

while Timer > 0 do -- checks if the timer is higher than zero, if it is it does this loop

    Timer = Timer - 1 -- reduces the timer
    wait(1) -- waits 1 second before doing the loop again
    script.Parent.Parent.Time = Timer -- sets the text label to the timer
end -- ends the code block

if Timer == 0 then -- if the timer is 0 it does the following
Timer = 60 -- resets the timer
end -- ends the code block

and we are done! if this helped please give me an upvote!

Log in to vote
0
Answered by
NGC4637 602 Moderation Voter
3 years ago

heres a simple timer script, i will place notes throughout the script so you understand what I'm doing

-- this is a note (actually it called a comment but whatever)

Code:

timer = 60 -- this is a one minute timer (since 60 seconds is one minute)

while true do -- infinite loop
    timer -= 1 -- timer = timer - 1 but shorter
    if timer == 0 then -- if the timer reaches 0
        break -- stop the loop
        timer = 60 -- timer becomes back to 60
    end
    wait(1) -- make the infinite loop repeat every 1 second (without the wait, you will just make a lag spike lol)
end

Answer this question