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

scripting eof error near elseif?

Asked by 9 years ago

Hi I have been making a game script and I while i was scripting it keeps saying <eof> error expected near elseif. Can you please help with my eof scripting error?? (The error is near the elseif I think it might need another end?) I also need help understanding about the eof. So can you help?

local h = Instance.new("Hint", workspace)
local Players_Found_In_Game = {}
if game.Players.NumPlayers > 1 then
    while true do
    for g = 10, 0, -1 do
    h.Text = "There is " ..g.. " seconds left in the game"
    wait(1)
    h.Text = "Game ended!"
end
target = CFrame.new(-860.795, 804.22, 192.3) 
for i, player in ipairs(game.Players:GetChildren()) do
   if player.Character and player.Character:FindFirstChild("Torso") then
      player.Character.Torso.CFrame = target + Vector3.new(0, i * 5, 0)
   end
end
print("Players teleported!")
humanoid = v.Character:FindFirstChild("Humanoid")
humanoid.WalkSpeed = 16
for i,Child1 in ipairs(v.Backpack:GetChildren()) do
    if Child1.ClassName == "Tool" then
        Child1:Destroy()
    end
end

for i,Child2 in ipairs(v.Character:GetChildren()) do
    if Child2.ClassName == "Tool" then
        Child2:Destroy()
    end
end

end
wait(1)
for t = 10, 1, -1 do
h.Text = "Intermission " .." ("..t..")"
wait(1)
end
target = CFrame.new(-304.693, 1.5, 432.819) 
for i, player in ipairs(game.Players:GetChildren()) do
   if player.Character and player.Character:FindFirstChild("Torso") then
      player.Character.Torso.CFrame = target + Vector3.new(0, i * 5, 0)
   end
end
    print("Game started")
humanoid.WalkSpeed = 0
h.Text = "Game starting in 3"
wait(1)
h.Text = "Game starting in 2"
wait(1)
h.Text = "Game starting in 1"
wait(1)
h.Text = "Go!"

wait(0.5)

    for i,Child in ipairs(game.ServerStorage:GetChildren()) do
    Child:Clone().Parent = v.Backpack
    humanoid.WalkSpeed = 500

    game:GetService('Players').PlayerAdded:connect(function(player)

    player.CharacterAdded:connect(function(character)

        character:WaitForChild("Humanoid").Died:connect(function()


        end)
        end)
    end)


end

end
  elseif game.Players.NumPlayers < 1 then
    end
    h.Text = "There needs to be more then one player. Invite your friends!" 
end
end
end
end
0
Since it's a long script I sortve skimed over it but anyway. You have your h.Text our if the function so the unction already ended then u said what u said. Let me know if this helped. I'm on mobile if it's confusing. iSvenDerp 233 — 9y

2 answers

Log in to vote
0
Answered by 9 years ago

I am just scanning through your code, so I'm guessing you didn't add an end to one of your statements or loops.

Ad
Log in to vote
0
Answered by
M39a9am3R 3210 Moderation Voter Community Moderator
9 years ago

Your Problem

You had too many ends in some parts of your script, not finishing functions or ending if then statements.

Cleaned Up Code

Make sure that you tab your code correctly, or else you will continue to run into problems like such. Check out this Blog Article by CodeTheorem for more information!

local h = Instance.new("Hint", workspace)
local Players_Found_In_Game = {}
if game.Players.NumPlayers > 1 then
    while true do
        for g = 10, 0, -1 do
            h.Text = "There is " ..g.. " seconds left in the game"
            wait(1)
            h.Text = "Game ended!"
        end
        target = CFrame.new(-860.795, 804.22, 192.3) 
        for i, player in ipairs(game.Players:GetChildren()) do
            if player.Character and player.Character:FindFirstChild("Torso") then
                player.Character.Torso.CFrame = target + Vector3.new(0, i * 5, 0)
            end
        end
        print("Players teleported!")
        humanoid = v.Character:FindFirstChild("Humanoid")
        humanoid.WalkSpeed = 16
        for i,Child1 in ipairs(v.Backpack:GetChildren()) do
            if Child1.ClassName == "Tool" then
                Child1:Destroy()
            end
        end
        for i,Child2 in ipairs(v.Character:GetChildren()) do
            if Child2.ClassName == "Tool" then
                Child2:Destroy()
            end
        end
        wait(1)
        for t = 10, 1, -1 do
            h.Text = "Intermission " .." ("..t..")"
            wait(1)
        end
        target = CFrame.new(-304.693, 1.5, 432.819) 
        for i, player in ipairs(game.Players:GetChildren()) do
            if player.Character and player.Character:FindFirstChild("Torso") then
                player.Character.Torso.CFrame = target + Vector3.new(0, i * 5, 0)
            end
        end
        print("Game started")
        humanoid.WalkSpeed = 0
        h.Text = "Game starting in 3"
        wait(1)
        h.Text = "Game starting in 2"
        wait(1)
        h.Text = "Game starting in 1"
        wait(1)
        h.Text = "Go!"

        wait(0.5)

        for i,Child in ipairs(game.ServerStorage:GetChildren()) do
            Child:Clone().Parent = v.Backpack
            humanoid.WalkSpeed = 500
        end

        game:GetService('Players').PlayerAdded:connect(function(player)
            player.CharacterAdded:connect(function(character)
                character:WaitForChild("Humanoid").Died:connect(function()

                end)
            end)
        end)
    end
elseif game.Players.NumPlayers < 1 then

end

h.Text = "There needs to be more then one player. Invite your friends!"

Answer this question