Animation not working on click

i tried write other code but its not working
my animation published but still not working

--server script
local tool = script.Parent
local remote = tool:WaitForChild("M1Hammer")
local animation = tool:WaitForChild("M1Anim")

remote.OnServerEvent:Connect(function(player)
	local character = player.Character
	if not character then return end

	local humanoid = character:FindFirstChildOfClass("Humanoid")
	if humanoid then
		local track = humanoid:LoadAnimation(animation)
		track:Play()
	end
end)

--local script
local tool = script.Parent
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local remote = tool:WaitForChild("M1Hammer")

tool.Equipped:Connect(function()
	mouse.Button1Down:Connect(function()
		if not player.Character then return end

		remote:FireServer()

		local hrp = player.Character:WaitForChild("HumanoidRootPart")
		local frontOffset = CFrame.new(0, 0, -3.5)
		local spawnPosition = hrp.CFrame:ToWorldSpace(frontOffset).Position

		local part = Instance.new("Part")
		part.Size = Vector3.new(5, 5, 5)
		part.Position = spawnPosition
		part.Anchored = true
		part.CanCollide = false
		part.Material = Enum.Material.SmoothPlastic
		part.Color = Color3.fromRGB(255, 0, 0)
		part.Parent = workspace

		game.Debris:AddItem(part, 2)
	end)
end)
![Matchmaking🎮 - Roblox Studio 2025-08-24 22-46-24|video](upload://pKwrPo0NQKIVovxrBY7V2wUR66A.mp4)

Humanoid:LoadAnimation() is deprecated, use Animator:LoadAnimation() instead. and i prefer you play animations locally for responsiveness

i using r6 not r15 and humanoid:loadanimation() is on server script

  1. Animations should be loaded on the client (in LocalScripts)
  2. Humanoid:LoadAnimation() is deprecated so preferably use Humanoid.Animator:LoadAnimation()

The functionality of your code simply plays an animation and doesnt need a remote event, Here’s the new code.

Local Script

--local script
local debrisService = game:GetService("Debris")
local playerService = game:GetService("Players")

local tool: Tool = script.Parent
local player = playerService.LocalPlayer
local mouse = player:GetMouse()

local character: Model = nil
local humanoidRootPart: BasePart = nil
local animator: Animator = nil

local animation = tool:WaitForChild("M1Anim")
local animationTrack: AnimationTrack = nil

local frontOffset = CFrame.new(0, 0, -3.5)
local hitboxSize = Vector3.new(5, 5, 5)

-- functions

local function createHitboxPart(position)
	local part = Instance.new("Part")
	part.Size = hitboxSize
	part.Position = position
	part.Anchored = true
	part.CanCollide = false
	part.CastShadow = false
	part.Material = Enum.Material.SmoothPlastic
	part.Color = Color3.fromRGB(255, 0, 0)
	part.Transparency = 0.5
	return part
end

-- connections

local equipped = false
tool.Equipped:Connect(function()
	equipped = true
	tool.Unequipped:Once(function()
		equipped = false
	end)
end)

-- dont nest connections, this will cause memory leaks
mouse.Button1Down:Connect(function()
	if not equipped or not character then return end
	local spawnPosition = humanoidRootPart.CFrame:ToWorldSpace(frontOffset).Position

	animationTrack:Play()
	local part = createHitboxPart(spawnPosition)
	part.Parent = workspace
	debrisService:AddItem(part, 2)
end)

player.CharacterAdded:Connect(function(new_character)
	character = new_character
	humanoidRootPart = character:WaitForChild("HumanoidRootPart")
	animator = character:WaitForChild("Humanoid"):WaitForChild("Animator")
	
	animationTrack = animator:LoadAnimation(animation)
end)

-- possibly change this to once as tools are removed until respawned..
player.CharacterRemoving:Connect(function()
	character = nil
	humanoidRootPart = nil
end)

The Video your provided was in the script.

new code? theres saying --Just a second

Don’t worry, its coming right now.

Yes its updated, is it working? also i removed the remote event as there’s no need.

now script not working fully

--local script
local debrisService = game:GetService("Debris")
local playerService = game:GetService("Players")

local tool: Tool = script.Parent
local player = playerService.LocalPlayer
local mouse = player:GetMouse()

local character = player.Character or player.CharacterAdded:Wait()
local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
local animator = character:WaitForChild("Humanoid"):WaitForChild("Animator")

local animation = tool:WaitForChild("M1Anim")
local animationTrack: AnimationTrack = nil

local frontOffset = CFrame.new(0, 0, -3.5)
local hitboxSize = Vector3.new(5, 5, 5)

-- functions

local function createHitboxPart(position)
	local part = Instance.new("Part")
	part.Size = hitboxSize
	part.Position = position
	part.Anchored = true
	part.CanCollide = false
	part.CastShadow = false
	part.Material = Enum.Material.SmoothPlastic
	part.Color = Color3.fromRGB(255, 0, 0)
	part.Transparency = 0.5
	return part
end

-- connections

local equipped = false

tool.Equipped:Connect(function()
	equipped = true
	tool.Unequipped:Once(function()
		equipped = false
	end)
end)

--[[

-- You can simply just use activated.

tool.Activated:Connect(function()
	if not equipped or not character then return end
	local spawnPosition = humanoidRootPart.CFrame:ToWorldSpace(frontOffset).Position

	animationTrack:Play()
	local part = createHitboxPart(spawnPosition)
	part.Parent = workspace
	debrisService:AddItem(part, 2)
end)

]]

mouse.Button1Down:Connect(function()
	if not equipped or not character then return end
	local spawnPosition = humanoidRootPart.CFrame:ToWorldSpace(frontOffset).Position

	animationTrack:Play()
	local part = createHitboxPart(spawnPosition)
	part.Parent = workspace
	debrisService:AddItem(part, 2)
end)

EDIT: I updated the code again (3 times).

animationTrack:Play() not working but i fixed and animation still not work just added animationTrack = animator:LoadAnimation(animation)
lol, i mean your script not working with animation just saying loadaniamtion etc, and i want to say Motor6d is interferes with animation playback?

why is this nil, arent you supposed to load the animation?

Mistakes can happen, but they can be fixed by you.

The animation track is nil load it to the humanoid’s animator.

bruh i miss clicked to solution😭

how i understand motor6d is problem for animation?, if yes idk how to grip to player hammer with correct orientation, grip editor cost 5$ i dont want waste it

soo i removed motor6d and find free tool grip editor now what need to write in local script

Just use Tool.Activated which will fire when clicked when equipped

Not working local tool = script.Parent
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild(“Humanoid”)

local animator = humanoid:FindFirstChildOfClass(“Animator”)
if not animator then
animator = Instance.new(“Animator”)
animator.Parent = humanoid
end

local animation = tool:WaitForChild(“M1Anim”)
local track

tool.Equipped:Connect(function()
track = animator:LoadAnimation(animation)
end)

tool.Activated:Connect(function()
if track then
track:Play()
end
end)

tool.Unequipped:Connect(function()
if track then
track:Stop()
end
end)

–until your answer i writed this but still not working