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.
Thanks!