Hello! I am trying to make a head appear on a screen, just like in Doom. (No: I am not recreating Doom in Roblox) For some reason, whenever I set a variable to the player's cloned character, it always resets itself to nil!
Here's my script which is called "1":
local cam = Instance.new("Camera", script.Parent)
cam.Name = "0"
cam.CameraType = "Scriptable"
repeat wait() until game.Players.LocalPlayer.Character ~= nil
wait(1)
local char = game.Players.LocalPlayer.Character:Clone(script.Parent.ViewportFrame)
char:WaitForChild("Animate"):Destroy()
char:WaitForChild("HumanoidRootPart").Anchored = true
cam.CameraSubject = char.Head
cam.CFrame = char.Head.CFrame * CFrame.Angles(0, math.rad(180), 0) * CFrame.new(0, 0, 5)
My GUI contains a ViewportFrame, a script and a camera, which is created by the script.
For some reason, the character is not going inside the frame.
Please help me!
Solution:
I just cloned different accessories including the head. Turns out that the whole avatar is not Archived; thanks, AmazingLeobreaker66!
Thank you for trying to figure this out, BlackOrange3343, but your script didn't work.
Here is my script now:
local cam = Instance.new("Camera", script.Parent)
cam.Name = "0"
cam.CameraType = "Scriptable"
script.Parent.ViewportFrame.CurrentCamera = cam
repeat wait() until game.Players.LocalPlayer.Character ~= nil
wait(1)
local head = game.Players.LocalPlayer.Character:WaitForChild("Head"):Clone()
head.Parent = script.Parent.ViewportFrame
head.Anchored = true
cam.CameraSubject = head
cam.CFrame = head.CFrame * CFrame.Angles(0, math.rad(180), 0) * CFrame.new(0, 0, 2)
for _, v in pairs(game.Players.LocalPlayer.Character:GetChildren()) do
if v:IsA("Accessory") then
local i = v.Handle:Clone()
i.Parent = script.Parent.ViewportFrame
i.Anchored = true
end
end
Thanks for all the support!
Result:

3 comments
You can't clone the player's character, it's not archivable.(I think)
hmm... ok
You can just set Archivable to true on all the parts.