Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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)

4 comments

0

What it is saying is you need more ends to "close the function at line '6'"

0

How many more do I need? I have six, I think that's the amount I need.

2

else and elseif don't need to be ended, they are part of the initial if statement.

0

Thank you! That fixed it.

1 answer

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

1 comment

0

Forget other end.

This discussion is preserved as it was. New answers, comments, and votes are closed.