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

Why does it show error on the "end)" when it has a bracket?

Asked by 4 years ago

This script looks correct to me, I may be wrong but the error is showing at the end.

game.Players.PlayerAdded:Connect(function(player)

    player.CharacterAdded:Connect(function(character)
        if player.Name == "SomeDude" then
            print("Hi")

        if player.Name == "SomeOtherDude" then
            print("Hi")
        end 
    end) --//It shows the error here
end)

The error in the output is:

15:05:47.597 - ServerScriptService.OverheadGui:20: Expected identifier when parsing expression, got ')'

1
You forgot end for your first if statement. You can use elseif instead of making a new if statement. Block_manvn 395 — 4y
0
i like how everyone said the same exact answer xd NarwhalAndMe 141 — 4y
0
I didn't see that XD thanks kingblaze_1000 359 — 4y

3 answers

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

You missed the end in your first statement:

game.Players.PlayerAdded:Connect(function(player)

    player.CharacterAdded:Connect(function(character)
        if player.Name == "SomeDude" then
            print("Hi")
      end -- Missed the end here.
        if player.Name == "SomeOtherDude" then
            print("Hi")
        end 
    end)
end)

You can also use an elseif statement:

game.Players.PlayerAdded:Connect(function(player)

    player.CharacterAdded:Connect(function(character)
        if player.Name == "SomeDude" then
            print("Hi")

        elseif player.Name == "SomeOtherDude" then
            print("Hi")
        end 
    end)
end)

If you have any issues, feel free to comment back.

0
I didn't think of that, thanks for the advice! kingblaze_1000 359 — 4y
0
No problem! DiamondRules01 56 — 4y
Ad
Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

fix:

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character)
        if player.Name == "SomeDude" then
            print("Hi")
        end
        if player.Name == "SomeOtherDude" then
            print("Hi")
        end 
    end)
end)
0
Thanks kingblaze_1000 359 — 4y
0
yay i got an upvote :) User#29913 36 — 4y
Log in to vote
0
Answered by
JesseSong 3916 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago

That's because you cancel the end from your first if so for e.g.

game.Players.PlayerAdded:Connect(function(player)

    player.CharacterAdded:Connect(function(character)
        if player.Name == "SomeDude" then
end
            print("Hi")

        if player.Name == "SomeOtherDude" then
            print("Hi")
        end 
    end) 
end)

And remove the bracket on line 10

0
Oh thanks! kingblaze_1000 359 — 4y

Answer this question