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

Why is immediately stopping the code while it is not supposed to?

Asked by
MattVSNNL 620 Moderation Voter
3 years ago

I'm making a round system for a game and I made a game length variable to indicate when the time is up but right when it starts the game runs it even though there are 43 seconds left, Can anyone help me?

local gameLength = 43

for i = gameLength,0,-1 do

        for x, player in pairs(playersAlive) do
            if player then

                character = player.Character

                if not character then
                    -- Left the game
                else
                    if character:FindFirstChild("GameTag") then
                        -- They are still alive
                    else
                        -- They are dead
                        table.remove(playersAlive,x)
                        print(player.Name.." Has been removed!")
                    end
                end
            else
                table.remove(playersAlive,x)
                print(player.Name.." Has been removed!")
            end
        end

if i == 0 then
    status.Value = "Times up!"
    wait(2)
    break
end
0
Error message ? Omerevkizel 27 — 3y
0
nope MattVSNNL 620 — 3y
1
I am pretty sure you need to define player, player by its self is not a valid statement. Arkiteckt 38 — 3y
0
I dont know if this is the problem but you never added the end for the "for i = gameLength,0,-1 do" statement Omq_ItzJasmin 666 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

player is not a valid statement. You need to define it. You could try adding, local player = game:GetService("Players")

0
They have defined player, actually, in the "for x, player" statement. And I'm guessing that they classified "playersAlive" earlier in the script Omq_ItzJasmin 666 — 3y
0
Playersalive is a table to get every player MattVSNNL 620 — 3y
0
Oh shoot did not see that. Arkiteckt 38 — 3y
Ad

Answer this question