Hello. I am trying to grab the name of a Player from the Equipped function so I can move a script over. Is this possible.
I have already tried,
script.Parent.Equipped:Connect(function(player) print(player) end)
However when equipping the tool it prints out 'instance' and not the name of the player.
Thank you for your contributions.
you cannot grab the player inside the argument, but you can get the mouse through the args
script.Parent.Equipped:Connect(function(mouse) local character = script.Parent.Parent local player = game:GetService("Players"):GetPlayerFromCharacter(character) print(character.Name) end)
First of all, i believe the script should be inside the LocalScript.
local p = game.Players.LocalPlayer script.Parent.Equipped:Connect(function() print(p.Name) end)
So it would print out the player’s name, If you want it to be in a Server Script, use a RemoteEvent!
Here is an existing thread about it: https://scriptinghelpers.org/questions/53587/how-do-you-get-a-player-name-in-a-server-script