Hello scriptinghelpers community. For my game I have to get a Tools holder, so the Player the tool is in. How can I get that?
✓ ANSWER ACCEPTED
How do I get a tools holder/the player holding it?
2 answers
✓ Accepted answer
local tool = script.Parent -- change this to the tool's directory
tool.Equipped:Connect(function()
local player = tool.Parent
-- Insert desired code here
end
Though it was already answered by @programmerHere, this is the full script.
Be aware that I am not a professional scripter. Please do not judge me for my misconducts.
The way to get the player from the tool is to do this:
local tool = script.parent --Or any other directory.
local player = tool.parent --Write the code in this order, or else it will not work(I don't know why!).
An example of code using this:
local tool = script.parent
local player = tool.parent
tool.Activated:Connect(function()
player.head.BrickColor = BrickColor.Random() --Here is where I used it!
print("The player's head is a random color!")
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.

3 comments
In a Script/LocalScript,when the tool is equipped, tool.Parent is the character.
Thanks!
yep the tool always get from back pack to the character and back to packback. when it has a part that called handle it also can hold the tool in his hands