For the past couple of days, I’ve been messing around with Viewport Frames and cloning the player’s character to display within the Viewport Frame via script for GUI purposes, and its been a very interesting experience so far. However, 10% of that experience was progress and 90% of it was a complete roadblock on doing something as simple as making an animation play on the player’s cloned character displayed in a Viewport Frame. I’ve been trying to find a solution to this issue, both by myself and hours of searching through forums, but I genuinely cannot find one that helps since it’s so specific. These are the hierarchies, script, and video of what happens (and also what the animation is supposed to look like. FYI, there are no errors within the output.)
(video ^^^)
-- Variables
local uis = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local MouseInDisplay, HoldInDisplay = false, false
local currentX
-- Character Display
local VPFcam = Instance.new("Camera"); VPFcam.Parent = script.Parent.ViewportFrame
VPFcam.CFrame = CFrame.new(0,0,0)
script.Parent.ViewportFrame.CurrentCamera = VPFcam
repeat wait(.1) until game:IsLoaded()
char.Archivable = true
local ClonedChar = char:Clone()
ClonedChar.Parent = script.Parent.ViewportFrame.WorldModel
ClonedChar.Humanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None
ClonedChar:SetPrimaryPartCFrame(CFrame.new(Vector3.new(0,0,-9.5),Vector3.new(0,0,0)))
-- Turning Feature
uis.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
if MouseInDisplay == true then
HoldInDisplay = true
currentX = nil
end
end
end)
uis.InputEnded:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
HoldInDisplay = false
end
end)
script.Parent.ViewportFrame.MouseMoved:Connect(function(X,Y)
if HoldInDisplay == false then return end
if currentX then ClonedChar.PrimaryPart.CFrame *= CFrame.fromEulerAnglesXYZ(0,((X-currentX)*.025),0) end
currentX = X
end)
script.Parent.ViewportFrame.MouseEnter:Connect(function() MouseInDisplay = true end)
script.Parent.ViewportFrame.MouseLeave:Connect(function() MouseInDisplay = false end)
-- Animations
local animation = ClonedChar.Humanoid:LoadAnimation(script.Test)
animation:Play()
(I’ve also have not made the entirety of this script just to note)
I’m assuming there might be a very low chance that this is a bug because the :LoadAnimation() only works when a humanoid is in a workspace (because when the “ClonedChar.Parent =” is parented to the workspace, the animation applied on the clone via script will play within the workspace, but not within the WorldModel in the Viewport Frame), but when I use the same script but with a R6 rig within the WorldModel, for some reason, it works, but doesn’t work when the player is cloned? I’m not entirely sure, but if anyone has a fix for this, or would like to attempt to fix this, that would be greatly appreciated.