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

Can I take the name of a player from the .Equipped function?

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.

2 answers

✓ Accepted answer

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)

1 comment

0

you can only get the mouse if it is a localscript i believe,

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

1 comment

0

btw, u can use localscripts on tools since it is from ur backpack.

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