(Open) Only for scripters

Hey guys I need help fixing this script I am trying to make it loop but it keeps stoping after the time is up can you please help me fix this:
wait(0.5)

game.Players.LocalPlayer.PlayerGui.Timer.Enabled = true

local TimeUntilStart = 30

for count = 1 , 30 do

TimeUntilStart = TimeUntilStart - 1

game.Players.LocalPlayer.PlayerGui.Timer.Frame.TextLabel.Text = TimeUntilStart…" Seconds Until Next Round!"

wait(1.0)

end

local Minute = 4

local Seconds = 59

while true do

Seconds = Seconds - 1

if Seconds == 0 and Minute == 0 then

break

end

if Seconds == 0 then

Seconds = 59

Minute = Minute - 1

end

game.Players.LocalPlayer.PlayerGui.Timer.Frame.TextLabel.Text = Minute…“:”…Seconds…" Until Round Ends!"

if Seconds < 10 then

game.Players.LocalPlayer.PlayerGui.Timer.Frame.TextLabel.Text = Minute…“:”…“0”…Seconds…" Until Round Ends!"

end

wait(1.0)

end

game.Players.LocalPlayer.PlayerGui.Timer.Enabled = false

Minute = 0

Seconds = 5

local Copy = script:Clone()

Copy.Name = “TimerScript”

Copy.Parent = game.ReplicatedFirst

Copy.Disabled = true

wait()

script:Destroy()

1 Like

First, edit your post by surrounding your code with three backmarks (the ` symbols). It will make your code more readable:

-- Markdowned code
-- Place three `, press enter, paste your code, then on one more new line, place three more `
1 Like

Dude just you math.round.

1 Like

what do u mean?
can you explain

1 Like

I linked the API for you.

Basically math.round rounds away from zero. Typically the usual 0-0.4 = 0 | 0.5 - 0.9 = 1

1 Like

There are a couple of issues with your code, I’ll just state the obvious:

  • You don’t need to be calling game.Players.LocalPlayer.PlayerGui every time you want to get the Player’s GUI, instead you could just define a variable called: local PlayerGui = Player:WaitForChild("PlayerGui")

  • You concatenated with 3 dots instead of 2

  • Spacing, it hurts

local Player = game.Players.LocalPlayer
local PlayerGui = Player:WaitForChild("PlayerGui")
local TimeUntilStart = 30

PlayerGui.Timer.Enabled = true

for count = 1, 30 do
    TimeUntilStart = TimeUntilStart - 1
    PlayerGui.Timer.Frame.TextLabel.Text = TimeUntilStart.." Seconds Until Next Round!"
    wait(1)
end

local Minute = 4
local Seconds = 59

while true do
    Seconds = Seconds - 1

    if Seconds == 0 and Minute == 0 then
        break
    end

    if Seconds == 0 then
        Seconds = 59
        Minute = Minute - 1
    end

    PlayerGui.Timer.Frame.TextLabel.Text = Minute..":"..Seconds.. " Until Round Ends!"

    if Seconds < 10 then
        PlayerGui.Timer.Frame.TextLabel.Text = Minute..":"..0..Seconds.." ..Until Round Ends!"
    end
    wait(1)
end

PlayerGui.Timer.Enabled = false
Minute = 0
Seconds = 5

local Copy = script:Clone()
Copy.Name = "TimerScript"
Copy.Parent = game.ReplicatedFirst
Copy.Disabled = true
wait()
script:Destroy()

What exactly is happening then? Where does the script first start and stop?

1 Like