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

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

Asked by 5 years ago

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)
2
there's an end on line 11 that should be removed Vulkarin 581 — 5y
0
^^^ SmartNode 383 — 5y
0
You're ending the if statement on line 11 then continuing it and ending it again on line 15 gullet 471 — 5y
0
Usually it means you need to remove an end or you are missing one. Taureor 0 — 5y
0
hover the mouse over that "end)" and it would tell you the problem FirezoneGamez 155 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

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

Ad

Answer this question