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

Help with getting timer script to work, somehow using else instead of end?

Asked by 6 years ago

Hello, I am making a timer script that counts in Hours, Minutes, and Seconds, but at line 13 it always says "Expected 'end' (to close 'else' at line 12'), got else. No matter how many "end"s I put, the problem is never fixed. Here is the LocalScript:

function Count()
    wait(1)
    Seconds = Seconds - 1
    if Seconds == 0 then
        Minutes = Minutes - 1
        if Minutes == 0 then
            Hours = Hours - 1
            end
    end
    if Hours > 9 then
    if Minutes > 9 then
    if Seconds > 9 then
    script.Parent.Parent.Timer.Text = Hours..":"..Minutes..":"..Seconds
    else
    else
        else
    if Minutes > 9 then
    if Seconds > 9 then
    script.Parent.Parent.Timer.Text = "0"..Hours..":"..Minutes..":"..Seconds
else
    else
    if Seconds > 9 then
    script.Parent.Parent.Timer.Text = "0"..Hours..":0"..Minutes..":"..Seconds
    else
    script.Parent.Parent.Timer.Text = "0"..Hours..":0"..Minutes..":0"..Seconds
0
Indent your code properly. Not to be rude, but I can't read this giant mess. hiimgoodpack 2009 — 6y
0
If this is your whole Count() function, then please make sure that each `if`-statement is paired with an `end`. This is what this warning is telling you. XAXA 1569 — 6y
0
That script kills my eyes. Asceylos 562 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

Bundling 'if' statements into each other can cause errors. Place ends at the end of each 'if' statement or use the elseif condition.

Ad

Answer this question