local Players = game:GetService("Players")
local player = Players.LocalPlayer
local ViewportFrame = script.Parent
local char = player.Character or player.CharacterAdded:Wait()
repeat wait() until player.Character
print(char)
local charC = char:Clone()
print(charC)
charC.Parent = ViewportFrame
charC:PivotTo(CFrame.new(Vector3.new(0,0,0)))
#Why is this nil
1 messages · Page 1 of 1 (latest)
you're doing it in a server script
nvm
that's cus u print it before the charC is assigned a parent
when i try to parent it, it says "attempt to index nil with 'Parent'"
** You are now Level 11! **
try doing it with player.Character, also remove the repeat until, player.CharacterAdded:Wait() already waits for it
still not work
weird
Check the player model. If the Archivable property is set to false, it cannot be cloned.
its fixed now, thanks
oh right, the character is unarchivable at first
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local ViewportFrame = script.Parent
local char = player.Character or player.CharacterAdded:Wait()
- repeat wait() until player.Character
- print(char)
+ char.Archivable = true;
local charC = char:Clone()
+ char.Archivable = false;
- print(charC)
charC.Parent = ViewportFrame
charC:PivotTo(CFrame.new(Vector3.new(0,0,0)))
By default Player Characters .Archivable property is set to false, meaning when you clone it, it doesn't actually clone
Thus, setting it to true before cloning it will allow you to do so, and you can thereafter set Archivable back to false if you wish.
You also don't need the repeat wait() until player.Character segment, as this code is redundant since the player.CharacterAdded:Wait() await is sufficient. Essentially what your local char = player.Character or player.CharacterAdded:Wait() assignment is doing is setting local char equal to player.Character, and if the result is nil then we fallback to or, whereby we await the player.CharacterAdded event by using player.CharactedAdded:Wait()