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

How do I get the name of a player holding a tool?

My friend gave me this, and i put it in the tool script, but when i test it says player is a nil value

local Tool = script.Parent
local Player = game.Players:findFirstChild(Tool.Parent.Name)

1 comment

0

The first thing that comes to my mind is: Why is the F not capitalized? FindFirstChild needs it to be capitalized.

1 answer

✓ Accepted answer

The script running should be a LocalScript.

If the script is a LocalScript, then we can ask for the LocalScript to find the LocalPlayer executing the script.

local PlayerHoldingTheTool = game.Players.LocalPlayer
local PlayerName = PlayerHoldingTheTool.Name

PlayerHoldingTheTool is the LocalPlayer himself. PlayerName is his name.

If this helped, accept the answer! Hope this helped!

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