I got the error “unable to cast value to object” it was on line 7, could someone help me?
Line 7 is “local animationTrack = animator:LoadAnimation(animation)”
local player = game:GetService("Players").LocalPlayer
local character = player.Character
local animator = Instance.new("Animator")
animator.Parent = character.Humanoid
local animation = "rbxassetid://12769159721"
local animationTrack = animator:LoadAnimation(animation)
local canSwing = true
local debounce = 1
script.Parent.Activated:Connect(function()
if canSwing then
canSwing = false
animationTrack:Play()
wait(debounce)
canSwing = true
end
end)