Help animating tool

I followed this tutorial, but every time I equip the tool, it gets delete from the inventory after exactly 3 seconds.

It also locks me in the default animation when I launch it.

LocalScript in StarterPlayerScripts (has the same effect as in StarterCharacterScripts)

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()

local humanoid = character:WaitForChild("Humanoid")

local torso = character:FindFirstChild("Torso")

local toolMotor = Instance.new("Motor6D")
toolMotor.Name = "ToolMotor"
toolMotor.Part0 = torso
toolMotor.C0 = CFrame.new()
toolMotor.Parent = torso

local function onToolAdded(tool)
	if not tool:IsA("Tool") then return end

	local bodyAttach = tool:FindFirstChild("BodyAttach")
	if not bodyAttach then return end

	tool.CanBeDropped = false

	toolMotor.Part1 = bodyAttach
	bodyAttach.CFrame = torso.CFrame
end

local function onToolRemoved(tool)
	if toolMotor.Part1 and tool:IsA("Tool") then
		if toolMotor.Part1:IsDescendantOf(tool) then
			toolMotor.Part1 = nil
		end
	end
end

for _, child in ipairs(character:GetChildren()) do
	onToolAdded(child)
end

character.ChildAdded:Connect(onToolAdded)
character.ChildRemoved:Connect(onToolRemoved)

Help would be much appreciated!

The tool is being deleted because you’re welding it to the character from a LocalScript, which desyncs with the server, so move the Motor6D and attachment logic into a server Script (for example inside the Tool or ServerScriptService), attach using the Handle or a proper Attachment, and let the server control the weld so the tool isn’t auto-removed and animations don’t break.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.