So I'm making a text button that triggers only when a specific player presses it.
This is the code:
01 | local button = script.Parent |
02 |
03 | local groupServie = game:GetService( "GroupService" ) |
04 |
05 | button.MouseButton 1 Click:Connect( function (plr) |
06 | if plr.Name = = "ElpersonPL" then |
07 | print ( "good plr" ) |
08 | end |
09 |
10 | end ) |
The game says that I'm trying to index nil with "Name"
I think you have to get the LocalPlayer
instead of getting it from the parameter since I think it gets the player's mouse, not the player. Also, make sure it's a LocalScript
.
01 | local button = script.Parent |
02 |
03 | local groupServie = game:GetService( "GroupService" ) |
04 |
05 | local localPlayer = game:GetService( "Players" ).LocalPlayer |
06 |
07 | button.MouseButton 1 Click:Connect( function () |
08 | if localPlayer.Name = = "ElpersonPL" then |
09 | print ( "good plr" ) |
10 | end |
11 | end ) |