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

How can I get the player holding a tool?

If this is obvious, don't laugh at me, because I haven't learned the function/keyword/statement/method/whatever yet, obviously.

How do I tell which player is holding a tool?

2 answers

✓ Accepted answer
local Tool = script.Parent

Tool.Equipped:connect(function()
local Character = Tool.Parent
local Player = game.Players:GetPlayerFromCharacter(Character) -- Returns the player's object
print(Player)
end)

Tested and works.

1 comment

0

It does work! Thanks for your help!

The easiest way is to check all the players characters and using "FindFirstChild". If it's in a server script, you'd want to do

for _,character in pairs(workspace:GetChildren()) do
	if character:FindFirstChild("ToolName") then
		print('Found Tool') -- and place whatever you want here
	end
end

There are other methods, but this is the first that comes to mind. Hope that helps!

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