Tool Animation wont run when tool is in StarterPack

Hello, i have a problem where my tool animation wont run when i put it in starterpack but it runs perfectly in Workspace
this is the script

local character = player.Character
local animation = script.Parent:FindFirstChild("Animation")
local swingAnimation = character.Humanoid:LoadAnimation(animation)
local Sound = script:FindFirstChild("Sword Swing")

local canSwing = true

local debounce = 0.3

script.Parent.Activated:Connect(function()
	if canSwing then
		canSwing = false
		swingAnimation:Play()
		wait(debounce)
		wait(0.37)
		Sound:Play()
		canSwing = true
	end
end)

and i also get this error
image

the problem is that character can get redefined when the game is loading. a simple way to solve this would to just put a wait at the beginning. so something like wait(15). a more robust way would be to do something like:

if not character then 
    character = player.Character 
end
1 Like

thanks for reply, so you say i only need to put wait at the start?

I discourage using LoadAnimation on Humanoid and instead use it on Animator. LoadAnimation on Humanoid has been deprecated for a considerable amount of time now

2 Likes

no idea what u said but thanks

1 Like

Announcement about its deprecation:

Read the documentation about it here:

2 Likes

Hello, i tried what you said but its still not working

1 Like