Viewport frame won't load my character right for some reason

So I am trying to make viewport frame that renders player’s character, but the character wont show up in the frame. But let me say something funny, when I manually in game take the model out of the frame, and then put it back, the character shows up! I don’t know why is it happening so any help will be appriciated!
I don’t get any error in output btw

video of “funny thing”:

My script:

repeat task.wait(0.5) until game:IsLoaded()
local players = game:GetService("Players")
local replicated = game:GetService("ReplicatedStorage")
local plr = players.LocalPlayer

local function setUpViewports()
	 PlayerOneVPF = Instance.new("ViewportFrame")
	PlayerOneVPF.Parent = script.Parent
	local aspectRatio = Instance.new("UIAspectRatioConstraint")
	aspectRatio.Parent = PlayerOneVPF
	aspectRatio.AspectRatio = 1
	aspectRatio.AspectType = Enum.AspectType.FitWithinMaxSize
	PlayerOneVPF.Size = UDim2.new(0.1,0,1,0)
	PlayerOneVPF.Position = UDim2.new(0,0,0,0)
	 PlayerOneVPFCamera = Instance.new("Camera")
	PlayerOneVPFCamera.Parent = PlayerOneVPF
	PlayerOneVPF.CurrentCamera = PlayerOneVPFCamera
end

setUpViewports()

local plr1VPchar = nil
local plr2VPchar = nil

local function spawnCharactersToFrames(plr1, plr2)
	plr1.Character.Archivable = true
	local NpcToCopy = plr1.Character:Clone()
	NpcToCopy.Parent = PlayerOneVPF
	NpcToCopy.PrimaryPart.Position = Vector3.new(0,0,0)
	plr1VPchar = NpcToCopy
	local part = Instance.new("Part") --I rendered part here just to be sure the frame is working properly
	part.Parent = PlayerOneVPF
	PlayerOneVPFCamera.CFrame = CFrame.new(Vector3.new(0, 2, 12), part.Position)
end

spawnCharactersToFrames(plr)

Try putting the character inside a WorldModel, inside the ViewportFrame. This will keep the frame updated to always show what is inside. Without a WorldModel, it only renders the content inside once.

I tried adding worldModel, but still no difference. The character just won’t load until I manually re-add the character.

Did you put the character inside the world model?

yep, it looks like this:
image

Try having a script set the current camera of that viewport frame to a new camera on runtime. If that doesn’t work, I guess you could just have the script parent the character to the viewport frame twice, so it has to load.

The camera is already being assigned in script on runtime. I was sending screenshots from running game. And I just tried parenting it twice, but still no difference. I am kinda sure there is nothing wrong with the camera, since when I create part and parent it into the viewportframe, it renders as it should. So there must be something wrong with the character.

Would you mind trying it yourself? I know there is only a slim chance but it might be rb studio issue

Is the character in the correct position when placed in the world model? I’m pretty sure physics doesn’t exist in viewport frames, but I could be wrong. So maybe when you put the character in the workspace, it falls in the correct position when you put it back in the frame.

Yes, I set the character’s pivot to 0,0,0 and I am having the camera to look at those coordinates. And you are indeed right that there are not physics in viewport.

1 Like