Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago

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

Log in to vote
0
Answered by
Ziffixture 6913 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago

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!

0
thank you! Code1400 75 — 4y
Ad

Answer this question