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)