I need help with animations inside viewportframes

I am making an emote shop at my game and i want players to be able to preview the animations before buying them, so for that i’m using viewportframes .

Example of what i’m going for:

https://gyazo.com/43c81bf2b55f7510c77750e4122d1a09

This is the script i’m currently using and the result is in the image in this message:

local viewportFrame = Instance.new("ViewportFrame")
viewportFrame.Size = UDim2.new(0.3, 0, 0.4, 0)
viewportFrame.Position = UDim2.new(0, 15, 0, 15)
viewportFrame.BackgroundColor3 = Color3.new(0.196078, 0.196078, 0.196078)
viewportFrame.BorderSizePixel = 0
viewportFrame.Parent = script.Parent

local Character = game.ReplicatedStorage.Dummy
local clone = Character:Clone()
clone.Parent = viewportFrame

local viewportCamera = Instance.new("Camera")
viewportFrame.CurrentCamera = viewportCamera
viewportCamera.Parent = viewportFrame

viewportCamera.CFrame = CFrame.new(Vector3.new(0, 6, 6), clone.HumanoidRootPart.Position)

I tried this for animation but it didnt work, apparently the Dummy does not have the Animator inside of it. Which i tried to add manually and also do Humanoid:LoadAnimation() (Both did not work)

local humanoid = clone.Humanoid
local animation = script.Parent:WaitForChild("Animation")
local loadAnim = humanoid.Animator:LoadAnimation(animation)
loadAnim:Play()

Note: This is still in the same script

This is also my first time using ViewportFrames

Now what i need to do is make the animation play in the dummy, i would really appreciate some help, thanks.

image

Thanks!

What is the animation priority on the animation?

1 Like

I’m not sure, let me check real quick

I don’t really know, it’s just for dances and i made them sometime ago and i don’t really remember by now

But i think it’s Idle

Try changing the animation to Action, for that one is the highest priority.
image
If that doesn’t work, please let me know, Thanks! WE

Ah this. Sadly Viewports are still so limited, but so useful.
Disclaimer: I don’t know if it still works due to me not using viewports in a while.

But anyway, when I encountered this problem I found this video which helped me.

2 Likes

Now how do i add the animation to the Dummy in workspace?

This might be a dumb question but the method i used doesn’t work anymore

local humanoid = clone.Humanoid
local animation = script.Parent:WaitForChild("Animation")
local loadAnim = humanoid:WaitForChild("Animator"):LoadAnimation(animation)
loadAnim:Play()

But before you do this, you need to click Plugins, then Click on Animation Editor, then click on the Dummy and make an animation. Can be a minimalist, nothing animation. Save. This will generate the Animator.
You can delete the AnimSaves after.

1 Like