This code is just my first game and I am following a tutorial on yt. I have already worked hours on it and even more just doing research and doing everything I can to fix the code. Anyway i get this error message with the following code and really need help to fix it because i will probably give up:
for i = GameLength,0,-1 do
for x, player in pairs(plrs) do if player then character = player.Character -- Left the game else if character:FindFirstChild("GameTag") then -- They are still alive print(player.Name.."is still in the game!") else -- They are dead table.remove(plrs,x) end end else <------- THE ERROR IS RIGHT HERE AND SAYS "Error: (111,3) Syntax error: Expected 'end' (to close 'do' at line 93), got 'else''. table.remove(plrs,x) print(player.Name.."has been removed!") end wait(1) end
end
Note: I have made comments numbering each loop / if statement.
The reason you are getting the error is because the 'else' keyword does not operate with a 'for' loop, only with an 'if' statement.
for i = GameLength,0,-1 do -- 1 for x, player in pairs(plrs) do -- 2 if player then -- 3 character = player.Character -- Left the game else -- 3 if character:FindFirstChild("GameTag") then -- 4 -- They are still alive print(player.Name.."is still in the game!") else -- 4 -- They are dead table.remove(plrs,x) end -- 4 end -- 3 -- Removed else keyword from this location table.remove(plrs,x) print(player.Name.."has been removed!") end -- 2 wait(1) end -- 1 end --< Appears to be an extra 'end' keyword -- ^^ If you do not have another loop that requires this 'end' keyword, remove it.
Some extra information from Roblox: