Character not animating in a viewport

So i read that if i used a World Model i could be able to animate characters. So using this i made this script.

The animation is an animation Instance with my own animation i made. However the animation stops as soon as it starts
image

Like this can someone help me make this play continuously like the arsenal one? I don’t want to use the old method of changing the character each time would rather use this! Thanks

Script
local Player = game.Players.LocalPlayer

local Character = Player.Character or Player.CharacterAdded:Wait()

local ViewPort = script.Parent

wait()

local Camera = Instance.new('Camera')

Camera.Parent = ViewPort

Camera.Name = 'ViewportCamera'

local WorldModel = Instance.new('WorldModel')

WorldModel.Name = 'WorldModel'

WorldModel.Parent = ViewPort

local CharacterViewPort = Character:Clone()

CharacterViewPort.Parent = ViewPort

ViewPort.CurrentCamera = Camera

local PrimaryPart = CharacterViewPort.PrimaryPart

local Size = CharacterViewPort:GetExtentsSize()

local LongestAxisSize = math.max(Size.X, Size.Y, Size.Z)

local Distance = LongestAxisSize * 2

Camera.CFrame = CFrame.new(PrimaryPart.Position + (PrimaryPart.CFrame.LookVector * LongestAxisSize * 1), PrimaryPart.Position)

local Humanoid = CharacterViewPort.Humanoid

local Anim = Humanoid:LoadAnimation(script.Parent.Dancing)

Anim.Looped = true

Anim:Play()
1 Like

Do

Anim.Priority = Enum.AnimationPriority.Action

and tell me if that works.

(It sets the Priority of the animation to the highest making it the animation that should be overwriting every other animation.)

Tried that now its not even playing

Trying updating the CFrame every sec

Shouldn’t you use Render Stepped to bind a function to be ran before the frame renders. Also, you should update the CFrame for each children of your character. Not too sure, but perhaps Motor6Ds also work.

Try putting the character in the WorldModel. You created the WorldModel for no reason.