So I have this VPF script, which is suppose to clone children from the character and parent them to a VPF. Also, it sets the camera of the viewportframe to the workspace one, just to mimic the character in real time. It lastly updates the CFrame anytime the character moves. I have 2 issues with this. 1. Once the character resets or loads again, the viewportframe just decides to make my character a grey block character. 2. It doesn’t render accessories properly or just parts in general sometimes, like 1/20 chance for this to happen. But it’s still a problem nonetheless. Here’s my script:
#Viewportframes… why does it have to be viewportframes bro
3 messages · Page 1 of 1 (latest)
local vpf = script.Parent:WaitForChild("CharacterVPF")
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
char.Archivable = true
local cam = workspace.Camera
vpf.CurrentCamera = workspace.CurrentCamera
local clonedChar = char:Clone()
clonedChar.Parent = vpf
for i, v in ipairs(clonedChar:GetDescendants()) do
if v:IsA("Script") or v:IsA("LocalScript") then
v:Destroy()
end
end
game:GetService("RunService").RenderStepped:Connect(function()
if char:FindFirstChild("HumanoidRootPart") then
for i, v in ipairs(char:GetDescendants()) do
if v:IsA("BasePart") then
local clonedPart = clonedChar:FindFirstChild(v.Name)
if clonedPart then
clonedPart.CFrame = v.CFrame
end
elseif v:IsA("Motor6D") then
-- Copy Motor6D transformations to mimic animations
local clonedMotor = clonedChar:FindFirstChild(v.Name)
if clonedMotor then
clonedMotor.Transform = v.Transform
end
elseif v:IsA("Accessory") then
for _, v in ipairs(char:GetDescendants()) do
if v:IsA("Accessory") then
local clonedPart = clonedChar:FindFirstChild(v.Name)
if clonedPart then
clonedPart:WaitForChild("Handle").CFrame = v:WaitForChild("Handle").CFrame
end
end
end
end
end
end
end)
I made like a thing where you can make a picture, I used this to clone everything:
--the map
for i,v in workspace.Map:GetDescendants() do
local v2 = v:Clone()
v2.Parent = VieuwportFrame
end
--for the players
for i,v in game:GetService("Players"):GetPlayers() do
local Chr = v.Character
Chr.Archivable = true
task.wait()
local char = Chr:Clone()
Chr.Archivable = false
char.Parent = VieuwportFrame
end