Unable to cast value to object error?

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)

The animation variable needs to be the ACTUAL animation object, like the animation object you insert to workspace or wherever.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.