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

Why isn't the if statement in my timer script working?

Asked by 6 years ago

Why isn't the if statement working on line 19?

local timeint = 57
local inttime = 5
local gametill = 5
local status = game.ReplicatedStorage.Status

if game.ServerScriptService.PlayerCount.Players.Value>=2 then   
    for i = inttime,1,-1 do
        wait(1)
        status.Value = "Intermission: "..i.." seconds."
    end
    for i = gametill,1,-1 do
        status.Value = "Game starts in "..i.." seconds!"
        wait(1)
    end
    status.Value = "Capture the enemy's flag!"
    wait(3)
    for i = timeint,1,-1 do
        status.Value = "Game Time: "..i.." seconds."
        if status.Value ~= "Game Time: "..i.." seconds." then
            wait(10)
        end
        wait(1) 
    end
else
    status.Value = "Waiting for more players to join."
end

There's a different text that comes up and the gui doesn't wait 10 seconds.

0
Is this a server script or a local script? Always important. hiimgoodpack 2009 — 6y
0
server script rilgundam 65 — 6y
0
for i=inttime,0,-1 do instead of for i=inttime,1,-1 do PyccknnXakep 1225 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

It probably does, just at the wrong times. This only checks once, and does not if another player joins. This has a simple fix. Use this.

local timeint = 57
local inttime = 5
local gametill = 5
local status = game.ReplicatedStorage.Status

game.Players.PlayerAdded:Connect(function()
    if #game.Players:GetPlayers() >= 2 then --Use your useful roblox functions, man.  
        for i = inttime,1,-1 do
            wait(1)
            status.Value = "Intermission: "..i.." seconds."
        end
        for i = gametill,1,-1 do
            status.Value = "Game starts in "..i.." seconds!"
            wait(1)
        end
        status.Value = "Capture the enemy's flag!"
        wait(3)
        for i = timeint,1,-1 do
            status.Value = "Game Time: "..i.." seconds."
            if status.Value ~= "Game Time: "..i.." seconds." then
                wait(10)
            end
            wait(1) 
        end
    else
        status.Value = "Waiting for more players to join."
    end
end)

Hope this helps!

0
It still doesn't work rilgundam 65 — 6y
0
i've dealt with countdowns, use *for i=inttime,0,-1 do* instead PyccknnXakep 1225 — 6y
0
its not the countdown, its the if statement rilgundam 65 — 6y
0
Simple question. Are there 2 players? hiimgoodpack 2009 — 6y
View all comments (2 more)
0
I changed the script so that if I'm in there the timer starts rilgundam 65 — 6y
0
YOU COULD NOT ANSWER THE SIMPLE QUESTION? hiimgoodpack 2009 — 6y
Ad

Answer this question