local npc1 = game.Workspace.OldMan script.Parent.Touched:Connect(function() local Animation = Instance.new("Animation",npc1) Animation.Name = "LookAnim1" local Anim = require(game.Workspace.AnimationID) Animation.AnimationId = Anim.LookAfterEntering local Humanoid = npc1:WaitForChild("Humanoid") Humanoid:LoadAnimation(Animation) Animation:Play() end)
Here is my script, I'm trying to make a touched event that will make an npc do an animation. But the output says "Play is not a valid member of Animation".
I hope somebody can help me, thanks!
You need to call the :Play()
method on the AnimationTrack
Instance returned from the :LoadAnimation()
function called on the Humanoid:
local Anim = require(workspace.AnimationID) local OldMan = workspace.OldMan local Part = script.Parent Part.Touched:Connect(function() local Animation = Instance.new("Animation") Animation.Name = "LookAnim1" Animation.AnimationId = Anim.LookAfterEntering Animation.Parent = OldMan local Humanoid = OldMan:WaitForChild("Humanoid") local Track = Humanoid:LoadAnimation(Animation) Track:Play() end)