You dont need the CharacterAdded as that only fires upon your character being added, but this function doesnt fire then and you already have a WaitForChild for the character in the beginning of the script.
ok So the error with CharacterM being nil is because when trying to clone a character you have to manually set Archivable to true to allow it to be copied else when you try cloning it will just return nil.
The code below should fix that problem and I have included a better way of getting character than what was in previous code
Here just updated to use player and character variables again. So in the Update() function it will try getting player.Character if it canāt it will wait for character to be added
local Viewport = script.Parent
local player = game.Players.LocalPlayer
local Character = player.Character or player.CharacterAdded:wait() -- this will get your character when its loaded
script.Parent.body.HumanoidRootPart.CFrame = game.Workspace.Angles.CharArea.HumanoidRootPart.CFrame
local Cam = Instance.new("Camera")
Cam.Name = "Vyam"
Cam.Parent = game.Workspace
Cam.CFrame = CFrame.new(-84.51, 114.878, -271.133) *CFrame.Angles(math.rad(0),math.rad(-90),math.rad(0))
wait(2)
script.Parent.CurrentCamera = Cam
function update()
Character = player.Character or player.CharacterAdded:wait() -- this will get your character when its loaded
player.Character.Archivable = true -- this allows you to clone the players character else it will just return nil
local CharacterM = Character:Clone()
local Current = script.Parent.body
Current.Parent = game.Workspace
local HRP = CharacterM:WaitForChild('HumanoidRootPart') -- waits for the hrp to be created in the clone
HRP.CFrame = Current.HumanoidRootPart.CFrame
Current:Destroy()
CharacterM.Name = "body"
CharacterM.Parent = script.Parent
end
wait(3)
local Go = true
while Go do
wait(1.5)
update()
end
Oh well dang I forgot I had that there.
Just tested this, it is not showing up the character at all and in the Console it is telling me that there is a infinite yield possible on
Players.caleb200ss.PlayerGui.CharCreate.Char.body.Head:WaitForChild("something right here")
my screen for some odd reason wonāt let me see the rest of what it says in the waitforchild.
Iām going to try using the Archivable with the other code I have and see what happens.
The HRP gets deleted upon the function being called so it will error out as expected. You need to set āAreaSā to a new CFrame value (being the CFrame of the HRP), not the CFrame property of that Instance since that gets deleted.
To get the CFrame value just enter print(locationofHRP.CFrame) into the command bar and copy and paste the output to the line that you set AreaS
I think this might solve it, I added the Archivable thing and now its deleting the char from the gui and putting him back into the body every 1.5 sec (Updating) its just not in the view, and this should fix the view. Iāll let yall know in a few min.
Would I put the Cframe like this?
local AreaS = -78.257, 113.886, -271.192
Or should I put quotes around the location/position?
It errors at
CharacterM.HumanoidRootPart.CFrame = AreaS
local AreaS = CFrame.new(-78.257, 113.886, -271.192)
What Nyonic said, you always want to put CFrame.new around it when setting that or Roblox wont understand what those set of numbers are for, lol.
Its updating the character still but still not showing him on the frame itself.
CODE
local Viewport = script.Parent
local player = game.Players.LocalPlayer
local Charact = player.Name
local Character = game.Workspace:WaitForChild(Charact)
local AreaS = CFrame.new(-78.257, 113.886, -271.192)
script.Parent.body.HumanoidRootPart.CFrame = game.Workspace.Angles.CharArea.HumanoidRootPart.CFrame
local Cam = Instance.new("Camera")
Cam.Name = "Vyam"
Cam.Parent = game.Workspace
Cam.CFrame = CFrame.new(-84.51, 114.878, -271.133) *CFrame.Angles(math.rad(0),math.rad(-90),math.rad(0))
wait(2)
script.Parent.CurrentCamera = Cam
function update()
local player1 = game.Players.LocalPlayer
player1.Character.Archivable = true -- this allows you to clone the players character else it will just return nil
print("Oh my")
local Character = game.Workspace:WaitForChild(player1.Name)
print("Character Found")
local CharacterM = Character:Clone()
local Current = script.Parent.body
CharacterM.HumanoidRootPart.CFrame = AreaS
Current:ClearAllChildren()
print("Cleared Children")
CharacterM.Parent = Current
print("Moved Character to Body")
end
wait(3)
local Go = true
while Go do
wait(3)
update()
print("Updating..")
end
try changing the cams parent to the viewportframe like this:
Cam.Parent = script.Parent
Nope not working. R.i.P. You would think this would be a lot more simple.
Iām tired and going to bed for the night, maybe Iāll be able to come up with an idea tomorrow, thanks for the help.
Feel free to reply with anything that you think might fix it, or work for it.
Move the line where it sets the camera CFrame to inside the update() function, and instead of setting it to set coordinates, set it relative to the characterās HRP:
CFrame.new(CharacterM.HumanoidRootPart.Position + CharacterM.HumanoidRootPart.CFrame.LookVector * 5, CharacterM.HumanoidRootPart.Position)
I tested it out in studio and this line is the reason why it wouldnāt show:
CharacterM.HumanoidRootPart.CFrame = AreaS
The CFrame you recorded is probably off but you donāt need that line regardless, as the camera already updates its position so that it views in front of the character. I simplified your code a bit to look cleaner:
local Viewport = script.Parent
local player = game.Players.LocalPlayer
local Character = game.Workspace:WaitForChild(player.Name)
local Cam = Instance.new("Camera")
Cam.Name = "Vyam"
Cam.Parent = script.Parent
Viewport.CurrentCamera = Cam
function update()
player.Character.Archivable = true
Viewport.body:ClearAllChildren()
local CharacterM = player.Character:Clone()
CharacterM.Parent = Viewport.body
Cam.CFrame = CFrame.new(CharacterM.HumanoidRootPart.Position + CharacterM.HumanoidRootPart.CFrame.LookVector * 5, CharacterM.HumanoidRootPart.Position)
end
wait(3)
local Go = true
while Go do
wait(3)
update()
print("Updating..")
end
Thank you, thank you, thank you. It works, all that I really gotta do is make the update faster and it works exactly how I want it. Though for some odd reason the characters head turns every now and then, I believe this is just because I left the animation script there. Nope that was not it. Do you know of any way I can just make them stand still. Because it like shows if they are jumping ect, is it possible just to show them standing their still?
EDIT 2: Actually I think I can just solve this by making it so the player cannot jump or walk while in the creation menu.
No problem, you can just do what you said or to guarantee a still character have a R15 rig in ReplicatedStorage, then have the server clone the rig and call ApplyDescription to apply your characterās description to the rig, then parent it into the ViewportFrame.
Alright, and once again thank you for all this help.