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

How do I fix "Expected <eof>, got 'elseif'"?

Asked by 2 years ago

I am a bit new to scripting so can someone help me (don't question the Obama)

elseif map:FindFirstChild("Obama") then (elseif is the error)

It stops the intermission and prevents the game from working

I'm not sure what code makes the problem and why there's a problem

The error: Expected <eof>, got 'elseif'

local status = game.ReplicatedStorage.Status
local maps = game.ReplicatedStorage.Maps:GetChildren()
while true do 
    for i = 1,30 do
        status.Value = "Intermission "..30-i
        wait(1)
    end

    local rand = math.random(1, #maps)

    local map = maps[rand]:Clone()
    map.Parent = workspace

    status.Value = "map is "..map.Name
    wait(4)
    local players = game.Players:GetChildren()
    for i = 1,#players do
        if players[i].Character ~= nil then
            local spawnLocation = math.random(1,#workspace.Teleports:GetChildren())
            players[i].Character:MoveTo(workspace.Teleports:GetChildren()[spawnLocation].Position)
            players[i].Character.Parent = workspace.Ingame
        end
    end

    local roundLength = 999999
    local canWin = true
    local roundType = ""

    if map:FindFirstChild("the happy home of robloxia") then
        roundType = "House"
    end
end

elseif map:FindFirstChild("Obama") then
    roundType = "Obama"

    local children = workspace.Ingame:GetChildren()
    for i = 1,#children do
        map:FindFirstChildWhichIsA("Tool"):Clone().Parent = child[i]
    end

    map:FindFirstChildWhichIsA("Tool"):Destroy()
end
repeat
    roundLength = roundLength -1
    status.Value = "Time Left"..roundLength
    wait(1)
until roundLength == 0 or canWin == false or #workspace.Ingame:GetChildren() == 0 or (#workspace.Ingame:GetChildren() == 1 and roundType == "Obama")

if #workspace.Ingame:GetChildren() == 1 and roundType == "Obama" then
    status.Value = workspace.Ingame:FindFirstChildWhichIsA("Model").Name.. " is better than u"
end
wait(3)
map:Destroy()

local players = game.Players:GetChildren()
for i = 1, #players do
    if players[i].Character ~= nil then
        players[i]:LoadCharacter()
    end
end

I tried to fix the problem myself and by looking on google but I couldn't fix the bug Game link:

1 answer

Log in to vote
0
Answered by 2 years ago
Edited 2 years ago

A bit of information before we start: <eof> is end of file, so the script expects it to end.

Alright, so. This should be pretty easy. There's no if statement to elseif. The elseif is outside of an if statement so it broke. Think of the elseif statement in this case as like an outsider, or a child of a parent. Without a parent, a child cannot be controlled, thus throwing an error in this type of thing.

<eof> error example:

if true then
    print("hello")
end

elseif false then
    print("false")
end

Output:

Expected <eof>, got elseif

It's an easy fix, really.

The correct way:

if true then
    print("Hello")
elseif false then
    print("false")
end

Output:

Hello

And if you're new, I advise going down on the DevHub. If you don't understand something, you can ask in DevForum or ScriptingHelper, or Youtube! There are a lot of resources that you can use to improve your scripting style and competence. And before I go:

Welcome to the world of Scripting.

0
Thank you! EPICdragon786 2 — 2y
0
Make this an accepted answer! He deserves some points for making this detailed answer. PaleNoobs 37 — 2y
Ad

Answer this question