local part = script.Parent
local clickDetector = part:FindFirstChild("ClickDetector")
local function onClicked(player)
local character = player.Character
if character then
local humanoid = character:FindFirstChild("Humanoid")
if humanoid then
-- Unequip tools before moving
humanoid:UnequipTools()
local tool = humanoid:FindFirstChildWhichIsA("Tool")
if tool then
tool.Parent = part
tool.Handle.CFrame = part.CFrame
end
end
end
end
-- Ensure that clickDetector is not nil
if clickDetector then
clickDetector.MouseClick:Connect(onClicked)
else
warn("ClickDetector not found in part")
end
I made a script that when I click a part, my equipped tool should go to the part. It doesn’t happen though and there are no errors