Hello, i’m having a problem with the Clone() Function.
Basically, i’m trying to clone the player’s character so it can be shown in a ViewportFrame.
My code works fine until the cloning itself. The player model is cloned and put in the right location, however, no childs are cloned, which makes cloning the model useless. I can’t figure out why this happens, can someone help me? or is this an engine bug?
Code:
local NewCharacter
local Camera = Instance.new("Camera")
local Viewport = script.Parent:WaitForChild("ViewportFrame")
Camera.Parent = script
local Player = game:GetService("Players").LocalPlayer
print(Player)
local Character = Player.Character
Character.Archivable = true
local NewCharacter = Character:Clone()
print(NewCharacter)
NewCharacter.Parent = workspace
NewCharacter.Torso.Position = Vector3.new(0,0,0)
Camera.CameraSubject = NewCharacter.Humanoid
I’m fairly sure now that it’s because your character’s model hasnt fully loaded yet. For whatever reason, R6 characters don’t get created with all appearance stuff loaded whereas R15 characters do. Operatik’s test ran OK since they were using R15 while yours didn’t since you were using R6.
Run the following on top of the script:
local LocalPlayer = game.Players.LocalPlayer
if not LocalPlayer:HasAppearanceLoaded() then
LocalPlayer.CharacterAppearanceLoaded:Wait()
end