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

Countdown timer starts at 0 and not the correct number, it does not countdown as well, how to fix?

Asked by
bailley5 114
3 years ago

I have made a timer admin command, it is suppose to copy the timer gui to the playergui (for all players) then countdown the timer that was giving to it through the chat. The gui part works fine however the countdown does not work and it starts at 0 instead of the timer value.

commands.timer = function(sender, arguments)
    local Timer = arguments[1]

    print(Timer)

    if Timer then
        for p, v in pairs(game.Players:GetChildren()) do
            local timerc = RS.Timer:Clone()
            timerc.Parent = v.PlayerGui

        for i = Timer, 0, -1 do
            timerc.Outer.Inner.TextLabel.Text = i
        end
        end
    end
end

1 answer

Log in to vote
1
Answered by 3 years ago
Edited 3 years ago
commands.timer = function(sender, arguments)
    local Timer = arguments[1]

    print(Timer)

    if Timer then
        for p, v in pairs(game.Players:GetChildren()) do
            local timerc = RS.Timer:Clone()
            timerc.Parent = v.PlayerGui

        for i = 0, Timer, -1 do
            timerc.Outer.Inner.TextLabel.Text = i
        end
        end
    end
end

pretty certain thats all. Last time I checked it was that the first number was the minimum and the second was the max and the third was in what direction it goes in. like this:

min = 1
max = 10
direction = 1

for i = min, max, direction do
    print(i)
end
-- Should print:
1
2
3
4
5
6
7
8
9
10

Because you had -1 as the direction it's clear you want it going down. But in the order you originally had you'd have to change the -1 to a 1 to make it go up.

Because you had "Timer" at the start, it thinks that's the min and the 0 is the max, so it starts at 0 and ends at 0 because of the way you're doing it. Hopefully this helped

0
Now the textlabel doesn't display any number just the default text I set it. bailley5 114 — 3y
0
Hmm. Let me check my code and see whats going on. jasperagent 43 — 3y
0
Ok this isn't exactly what you did but it was the best I could do: function Timer(sender, args) local TimeSent = args[1] print(TimeSent) if (TimeSent) then for i = TimeSent, 1, -1 do print(i) end end end Timer("Someone", {[1] = 60}) jasperagent 43 — 3y
0
you can change it however you tried doing it but it should just do your job with printing instead, so it should be an easy fix to make it a GUI jasperagent 43 — 3y
Ad

Answer this question