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

How can I make it so when it reaches ten, the restart script works?

Asked by 6 years ago
Edited by Shawnyg 6 years ago
-- The parent is TextLabel, TextLabel's parent is ScreenGui, ScreenGui's parent is StarterGui

Timer = 0
while Timer <10 do
Timer = Timer + 1
 Wait(1)
script.Parent.Text = (Timer)
end
-- This is the part that isn't working (below)
while Timer == 10 do
wait(1)
Game.workspace.Sound:play()
wait(1)
Timer = Timer - 9 
wait(10)
script.Parent.Text = (Timer)
end





0
I don't know why it's not showing it in the roblox format. Sorry User#20945 0 — 6y
0
You can put it in a code block (the button with the Lua symbol) to show it in code format. mattscy 3725 — 6y
0
Edited to put the code in a code block. Shawnyg 4330 — 6y

2 answers

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

Try this

Timer = 0
while Timer < 10 do 
  Timer = Timer + 1 
    wait(1)
      print(Timer)
      if Timer == 10 then 
    Timer = 0
   game.Workspace.Sound:play()
  wait(1)
 end
end

using if statements is easier than what you did. If this does work please hit the [Accept Answer] button below.

Ad
Log in to vote
0
Answered by
KenUSM 53
6 years ago
for i = 0, 10, 1 do 
    Timer = i
    wait(1)
    if Timer == 10 then 
        game.Workspace.Sound:Play()
    end
end

Answer this question