How do I find the name of the tool instead of the tool itself?
local inHand = hit.Parent:FindFirstChildWhichIsA(‘Tool’)
local inBackpack = player.Backpack:FindFirstChildWhichIsA(‘Tool’)
How do I find the name of the tool instead of the tool itself?
local inHand = hit.Parent:FindFirstChildWhichIsA(‘Tool’)
local inBackpack = player.Backpack:FindFirstChildWhichIsA(‘Tool’)
You can get the name of any instance by getting it’s Name
property, e.g. tool.Name
Actually, I believe you could do something like:
local tool = (hit.Parent:FindFirstChildWhichIsA("Tool") or player.Backpack:FindFirstChildWhichIsA("Tool"))
print(tool.Name)
Otherwise, :FindFirstChild("ToolName")
would do the trick.
But he’s trying to find the tool’s name.
Oh, thought he wanted to get the tool by name, never mind.
Thanks for all the great answers!
I think you can do something like this
hit.Parent.ChildAdded:Connect(function()
for _, child in pairs(hit.Parent:GetChildren()) do
if child:IsA("Tool") then
print(child.Name)
end
end
end
Basically it detect if a ChildAdded in the hit.Parent and check every children inside hit.Parent and if it’s a tool print it’s name, I don’t think this is the best solution but I think it helps with what you need