Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

unable to cast value to object, why isn't my animation working?-


local player = game.Players.LocalPlayer 
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local animation = Instance.new("Animation",character)
local animationId = "rbxassetid://4873199438"

if humanoid then
	wait(3)
local loadAnimation = character.Humanoid:LoadAnimation(animationId)
loadAnimation:Play()
end

1 answer

✓ Accepted answer

You need to cast the AnimationObject to the Humanoid, not the ID:

local Animation = Instance.new("Animation")
Animation.AnimationId = "rbxassetid://"..4873199438
Animation.Parent = Character --// Secondary argument of Instance.new was deprecated

Character.Humanoid:LoadAnimation(Animation):Play()

If that helped, don’t forget to accept this answer!

1 comment

0

thank you!

This discussion is preserved as it was. New answers, comments, and votes are closed.