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)
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
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