Rig won't play animation through ViewportFrame

Image of the viewport frame:
image

Script in the rig (that is onscreen):

print("loading")

local char = script.Parent

local hum = char.Humanoid

print("vars")

local anim = hum:LoadAnimation(script.Animation)

print("anim loaded")

anim.Looped = true

anim:Play()

print("anim playing")

It still prints everything, what do I do?

Can you screenshot your viewport frame in explorer?

To make NPC play animation in viewport frame you would need to insert WorldModel inside of viewport frame, and then parent NPC in WorldModel as well as set primary part of WorldModel to primary part of NPC, and then load your animation and play it, that should be solution for it, your code should look something like this:

local WorldModel = Instance.new("WorldModel")
WorldModel.Parent = ViewPortFrame -- define variable for viewport somewhere at top
char.Parent = WorldModel
WorldModel.PrimaryPart = char.PrimaryPart

local anim = hum:LoadAnimation(script.Animation)
anim.Looped = true
anim:Play()
2 Likes