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

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

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 ')'

3 comments

1

You forgot end for your first if statement. You can use elseif instead of making a new if statement.

0

i like how everyone said the same exact answer xd

0

I didn't see that XD thanks

3 answers

✓ Accepted answer

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.

2 comments

0

I didn't think of that, thanks for the advice!

0

No problem!

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)

2 comments

0

Thanks

0

yay i got an upvote :)

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

1 comment

0

Oh thanks!

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