How to change a default character into the character playing the game

Hey there,
I’m trying to make a GUI that displays the character playing the game onto a Viewpoint GUI, I’ve tried to find anything from :LoadCharacter. I want this to be done locally, is there any way I can make the local player see their character on the GUI?

Heres what I’m trying to achieve with my character below.
image

Thanks,

1 Like

You can do this by cloning the LocalPlayer’s Character, parenting it to the Viewport and adding/editing the viewport’s camera accordingly.

Firstly, we’ll get the LocalPlayer and define the viewport:

local player = game:GetService("Players").LocalPlayer
local viewportFrame = --define it

Secondly, clone the LocalPlayer’s character and parent it- make sure to Wait on CharacterAdded if they aren’t spawned yet.

local character = player.Character or player.CharacterAdded:Wait()
local clone = character:Clone()
clone.Parent = viewportFrame

Thirdly, make a camera for the viewporFrame and position it how you’d like:

local cam = Instance.new("Camera")
cam.Parent = viewportFrame
cam.CFrame = character.Head.CFrame * CFrame.new(0,0,-3) * CFrame.Angles(0, math.rad(180), 0) --Face them
cam.Focus = character.Head.CFrame
cam.CameraSubject = character.Head
cam.CameraType = Enum.CameraType.Fixed

Finally, set the viewportFrame’s CurrentCamera:

viewportFrame.CurrentCamera = cam
2 Likes

Hey, I’ve defined the viewpoint and got all the camera stuff sorted but I couldn’t see my character on the viewpoint frame. I’ve been getting the errors -

Players.H1ddenScript.PlayerGui.ScreenGui.LocalScript:5: attempt to index local ‘clone’ (a nil value)

and

Head is not a valid member of Model

I’m not sure if I made an error while trying to get the define stuff.

1 Like

Before:

local clone = character:Clone()

Try adding:

character:WaitForChild("Head")

It may be loaded but the Head might not be added yet.

Just saying, this code will break because player characters have their Archivable property enabled and thus a clone cannot be produced. You need to disable Archivable to clone a character properly, otherwise you may experience unexpected behaviour. If it is cloning normally, that’s unintended.

Ah, I never knew that.
Yeah, you may want to put:

character.Archivable = false

Before cloning it then.