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

For some reason my second last "end" is red underlined?

Please help, my second last "end" is red underlined?

game.Players.PlayerAdded:Connect(function(player)
	script.Parent.Touched:connect(function(hit)
		if hit.Parent:FindFirstChild("Humanoid") then
			--Player One--
			local Gui = script.Parent.Parent.PlayersInMatchPart.PlayersInMatchGui
			if Gui.Player1.Taken.Value == 1 then
				--Adding Player to Board
				Gui.Player1.Taken.Value = 2
				Gui.Player1.PlayerProfileImage.Image = "http://www.roblox.com/Thumbs/Avatar.ashx?x=100&y=100&Format=Png&userid="..player.UserId
				Gui.Player1.PlayerLabel.Text = player.Name
			end
			--Player Two--
			elseif Gui.Player2.Taken.Value == 1 then
				print("test")
			end
		end
	end) --This one
end)

5 comments

2

there's an end on line 11 that should be removed

0

^^^

0

You're ending the if statement on line 11 then continuing it and ending it again on line 15

0

Usually it means you need to remove an end or you are missing one.

0

hover the mouse over that "end)" and it would tell you the problem

1 answer

it is because you did

if Gui.Player1.Taken.Value == 1 then
--Adding Player to Board
	Gui.Player1.Taken.Value = 2
	Gui.Player1.PlayerProfileImage.Image = "http://www.roblox.com/Thumbs/Avatar.ashx?				x=100&y=100&Format=Png&userid="..player.UserId
	Gui.Player1.PlayerLabel.Text = player.Name
end
            --Player Two--
 elseif Gui.Player2.Taken.Value == 1 then
	print("test")
end

you shouldn't have two ends in an if statement with an elseif

----------------
--improper use--
----------------
if condition then

end

elseif condition2 then

end
--------------
--proper use--
--------------
if condition then

elseif condition2 then

end

so your script should look like this

game.Players.PlayerAdded:Connect(function(player)
    script.Parent.Touched:connect(function(hit)
        if hit.Parent:FindFirstChild("Humanoid") then
            --Player One--
            local Gui = script.Parent.Parent.PlayersInMatchPart.PlayersInMatchGui
            if Gui.Player1.Taken.Value == 1 then
                --Adding Player to Board
                Gui.Player1.Taken.Value = 2
                Gui.Player1.PlayerProfileImage.Image = "http://www.roblox.com/Thumbs/Avatar.ashx?x=100&y=100&Format=Png&userid="..player.UserId
                Gui.Player1.PlayerLabel.Text = player.Name
            --Player Two--
            elseif Gui.Player2.Taken.Value == 1 then
                print("test")
            end
        end
    end)
end)

as always, if there is anything I'm overlooking, just comment

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