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

Why is my Animation script not working when commanded?

An Animation is meant to load into the Humanoid and play. It didn't work. Here's the code:

--Vals--
local controller = script.Parent.Humanoid
local anim = Instance.new("Animation")
local humanoid = script.Parent.Humanoid

--Code--
anim.AnimationId = "rbxassetid://2510235063"
controller(anim.AnimationId):Play()
wait(2)
anim.AnimationId = "2510242378"
controller(anim.AnimationId):Play()
humanoid:MoveTo(211.5, 20, -1.35, workspace.RobinWalkToParts.Part1)
humanoid.MoveToFinished:Wait(0.1)
humanoid:MoveTo(191.75, 20, -1.35, workspace.RobinWalkToParts.Part2)

Anything wrong? Please help! Thx

1 comment

0

is the script in the player or npc

1 answer

Problems

  1. You were using the controller without :LoadAnimation()

Solution:

Use this when doing animations:

Code:

--Vals--
local controller = script.Parent.Humanoid
local anim = Instance.new("Animation")
local humanoid = script.Parent.Humanoid

--Code--
anim.AnimationId = "rbxassetid://2510235063"
controller:LoadAnimation(anim.AnimationId):Play()
wait(2)
anim.AnimationId = "2510242378"
controller:LoadAnimation(anim.AnimationId):Play()
humanoid:MoveTo(211.5, 20, -1.35, workspace.RobinWalkToParts.Part1)
humanoid.MoveToFinished:Wait(0.1)
humanoid:MoveTo(191.75, 20, -1.35, workspace.RobinWalkToParts.Part2)

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