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)

Animations should be loaded on the client (in LocalScripts)
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)
--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)
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?
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
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