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?
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?
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.
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.
1 comment
It does work! Thanks for your help!