✓ Accepted answer
If you want to get a tool that player is holding then you need to get it from Character:
local Player = game.Players.LocalPlayer
local findtool = function()
local tool = Player.Character:FindFirstChildWhichIsA("Tool")
if tool then
return tool
end
end
local tool = findtool()
print(tool.Name)
EDITED:
local Player = game.Players.LocalPlayer
local GetTool = function(toolname)
local found = nil
local tools = Player.Backpack:GetChildren()
local holdingtool = Player.Character:FindFirstChildWhichIsA("Tool")
for i,v in pairs(tools) do
if v.Name == toolname then
found = v
end
end
if holdingtool then
if holdingtool.Name == toolname then
found = holdingtool
end
end
if found ~= nil then
return found
end
end
Player:WaitForChild("Backpack").ChildAdded:Connect(function()
local tool = GetTool("Tool")
if tool then
print(tool.Name)
end
end)
Player.Character.ChildAdded:Connect(function()
local tool = GetTool("Tool")
if tool then
print(tool.Name)
end
end)
2 comments
change name to Name
It still doesnt work, @GamePlayer365247v2