So I'm making a text button that triggers only when a specific player presses it.
This is the code:
local button = script.Parent local groupServie = game:GetService("GroupService") button.MouseButton1Click:Connect(function (plr) if plr.Name == "ElpersonPL" then print("good plr") end 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
.
local button = script.Parent local groupServie = game:GetService("GroupService") local localPlayer = game:GetService("Players").LocalPlayer button.MouseButton1Click:Connect(function() if localPlayer.Name == "ElpersonPL" then print("good plr") end end)