Strange issue not letting me use game.Players.LocalPlayer.Character

hello, i’m working on a mirror in my game, and for some reason it is not letting me use game.Players.LocalPlayer.Character

my code is:

local vp = script.Parent.ViewportFrame
local cm = workspace:WaitForChild("CamModel")

repeat wait() until cm:WaitForChild("CamPart")

wait(1)

local cam = Instance.new("Camera")
cam.CFrame	= cm.CamPart.CFrame
cam.FieldOfView = 40
cam.Parent	= script
vp.CurrentCamera	= cam

cm.CamPart:GetPropertyChangedSignal("CFrame"):Connect(function()
	cam.CFrame = cm.CamPart.CFrame
end)

function RenderPlayer()
	local char = game.Players.LocalPlayer.Character:Clone()
	print(char)
	char.Parent = vp.Plr
end

wait(3)

while wait(.1) do
	vp.Plr:ClearAllChildren()
	RenderPlayer()
end

and each time i try to use this, i get this error:

i have tried adding CharacterAdded:Wait() but that made an infinite yield.

is there a fix for this?

Is the property “Archivable” enabled on the character? if not enable it.

Archivable just determines if an object can be saved when publishing your game or cloned with the “Instance:Clone()” method as specified by the docs.

This property determines whether an object should be included when the game is published or saved, or when Instance:Clone() is called on one of the object’s ancestors

(Source if youd like it Instance | Documentation - Roblox Creator Hub)

you can’t clone a character. You would have to reconstruct the character and use that as the clone (nvm proven wrong!)

ok but

how the heck do i do that

it is enabled, so i dont think that is the issue

1 Like

I think its the issue because if it was enabled you could easiely clone the character

in your case it printed nil

try this fix:

local vp = script.Parent.ViewportFrame
local players=game:GetService("Players")
local lplr=players.LocalPlayer
local cm = workspace:WaitForChild("CamModel")

repeat task.wait() until cm:WaitForChild("CamPart")

task.wait(1)

local cam = Instance.new("Camera")
cam.CFrame	= cm.CamPart.CFrame
cam.FieldOfView = 40
cam.Parent	= script
vp.CurrentCamera	= cam

cm.CamPart:GetPropertyChangedSignal("CFrame"):Connect(function()
	cam.CFrame = cm.CamPart.CFrame
end)

function RenderPlayer()
	if lplr.Character==nil then
		return
	end
	
	lplr.Character.Archivable=true
	for i,v in lplr.Character:GetDescendants() do
		v.Archivable=true
	end
	
	local char = lplr.Character:Clone()
	
	print(char)
	
	char.Parent = vp.Plr
end

task.wait(3)

while task.wait(.1) do
	vp.Plr:ClearAllChildren()
	RenderPlayer()
end

would test but my graphics card just died
image
hopefully this answer works though


this works but its a bit buggy, will make adjustments to fix those errors :slight_smile:

1 Like


better example

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.