#Anim code not working

2 messages · Page 1 of 1 (latest)

rose hemlock
#

I have some code, its supposed to play an anim when you click with a tool. I can see it on my end, but when I hopped into a team test with my friend he couldn't and I couldn't see his either. Code is a local script inside the tool, idk what to do and chatgpt doesn't either.

local tool = script.Parent
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://79508506978826" 

local animationTrack = humanoid:LoadAnimation(animation)
animationTrack.Priority = Enum.AnimationPriority.Action 

local cooldown = false
local cooldownTime = 2

tool.Activated:Connect(function()
    if not cooldown then
        cooldown = true
        animationTrack:Play()

        animationTrack.Stopped:Wait()

        wait(cooldownTime)

        cooldown = false
    end
end)
craggy dagger