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

Expected 'end' (to close 'function' at line 6) got 'elseif'?

Asked by 6 years ago

My script seems to think that I want to end my function. I don't.

At least that's what I think is happening. I really don't know. I saw another topic like this where the answer was "you're missing an end somewhere" or something along those lines, but I don't think I am, I've looked over the script several times.

What do you think is happening here? Here's my script:

print "Script is running"
local Part = game.Workspace:WaitForChild("MemorialCircleGPSSignal")
local Gui = game.Players.LocalPlayer.PlayerGui.MemorialCircleGPSSignalScreenGui.Frame
local JobDestination = game.Players.LocalPlayer.JobDestination.Value

Part.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") and game.Players.LocalPlayer.JobDestination.Value ~= "b" then
        Gui.Visible = true
        if game.Players.LocalPlayer.JobDestination.Value == "Rockland ME" or JobDestination == "Belfast ME" then
            Gui.TextLabel.Text = "Follow signs for North US 201/East US 202"
            end
        elseif JobDestination == "Farmington ME" or JobDestination == "Kingfield ME" or JobDestination == "Rumford ME" then  
             Gui.TextLabel.Text = "Follow signs for North ME-27/North ME-8/North ME-11"
        end
    elseif JobDestination == "Brunswick ME" then --error is here
        Gui.TextLabel.Text = "Follow signs for South US 201/South ME-27"
    end
else JobDestination = "Lewiston ME" or JobDestination == "Portland ME" or JobDestination == "Fryeburg ME" or JobDestination == "Biddeford ME" or JobDestination == "Sanford ME"
    end  
        wait(5)
        Gui.Visible = false
        end
end)
0
What it is saying is you need more ends to "close the function at line '6'" namespace25 594 — 6y
0
How many more do I need? I have six, I think that's the amount I need. sesamert16 31 — 6y
2
else and elseif don't need to be ended, they are part of the initial if statement. SummerEquinox 643 — 6y
0
Thank you! That fixed it. sesamert16 31 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago
Part.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") and game.Players.LocalPlayer.JobDestination.Value ~= "b" then
        Gui.Visible = true
        if game.Players.LocalPlayer.JobDestination.Value == "Rockland ME" or JobDestination == "Belfast ME" then
            Gui.TextLabel.Text = "Follow signs for North US 201/East US 202"
            end
        elseif JobDestination == "Farmington ME" or JobDestination == "Kingfield ME" or JobDestination == "Rumford ME" then  
             Gui.TextLabel.Text = "Follow signs for North ME-27/North ME-8/North ME-11"
        end

Supposed to be

Part.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") and game.Players.LocalPlayer.JobDestination.Value ~= "b" then
        Gui.Visible = true
        if game.Players.LocalPlayer.JobDestination.Value == "Rockland ME" or JobDestination == "Belfast ME" then
            Gui.TextLabel.Text = "Follow signs for North US 201/East US 202"
        elseif JobDestination == "Farmington ME" or JobDestination == "Kingfield ME" or JobDestination == "Rumford ME" then  
             Gui.TextLabel.Text = "Follow signs for North ME-27/North ME-8/North ME-11"
        end
0
Forget other end. Nooblics 0 — 6y
Ad

Answer this question