Issue with having viewport frames automatically update

Hello, I’m trying to make a simple stats UI and I’ve ran into a problem. I don’t have a single idea on how I can make it update? For example I want it to always be in the same pose, and most importantly have the same properties as the character. (e.g. transparency, etc.) Because whenever I change a property, it doesn’t change in the viewport. I’ve googled all over but I just can’t find a solution. Help would be appreciated

Code:

-- 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.Frame.ViewportFrame
VPFcam.CFrame = CFrame.new(0,0,0)
script.Parent.Frame.ViewportFrame.CurrentCamera = VPFcam

repeat wait(.1) until game:IsLoaded()

char.Archivable = true

if script.Parent.Frame.ViewportFrame.WorldModel:FindFirstChild(char.Name) then
	script.Parent.Frame.ViewportFrame.WorldModel:FindFirstChild(char.Name):Destroy()
end

local ClonedChar = char:Clone()

ClonedChar.Parent = script.Parent.Frame.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.Frame.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.Frame.ViewportFrame.MouseEnter:Connect(function() MouseInDisplay = true end)
script.Parent.Frame.ViewportFrame.MouseLeave:Connect(function() MouseInDisplay = false end)

Video:

Same problem here. all i can think of is every millionth of a second un - parenting then re -parenting the object.

You could respawn the viewport character every time a change is made to the player’s in-game character. However, I would recommend adding filtering to this - like only connecting v.Changed for accessories and body parts.

for _,v in ipairs(Player.Character:GetDescendants()) do
	v.Changed:Connect(function()
		--// Reset the viewportCharacter
	end)
end

Hope this helps!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.