very self explanatory
parenting the character to workspace
just doesn’t viewporet anything
:////
local function CreatePlayerViewport()
char.Archivable = true
-- clone the character
local clonedChar = char:Clone()
clonedChar.Parent = playerViewportFrame
print(clonedChar.Parent)
--clonedChar:PivotTo(viewportPart.CFrame)
-- delete unnecessary stuff from it (like animations)
for _, descendant in clonedChar:GetDescendants() do
if descendant:IsA("LocalScript") or descendant:IsA("Animator") then
descendant:Destroy()
end
end
-- get root part and create camera
local clonedRootPart: BasePart = clonedChar:FindFirstChild("HumanoidRootPart")
local viewportCamera = Instance.new("Camera")
viewportCamera.Name = "ViewportCamera"
-- clear previous content from viewport if exists
playerViewportFrame:ClearAllChildren()
-- set viewport camera parent
viewportCamera.Parent = playerViewportFrame
playerViewportFrame.CurrentCamera = viewportCamera
viewportCamera.CameraSubject = clonedChar
---- set camera cframe
local positionToBeAt = clonedRootPart.Position + Vector3.new(0, 1.5, -3) -- 1.5 studs above root part and 3 studs infront of it
viewportCamera.CFrame = CFrame.new(positionToBeAt, clonedRootPart.Position)
end