Hi all, thanks for reading in advance
At the moment, I’m having a bit of an issue with the playeradded event. Basically what I’m trying to do is create a clone of the player’s character when they respawn/join the game and put it into a viewport frame that’s inside an avatar customisation gui. I may be incorrectly using the event, I’m not sure but any help is appreciated.
local playerz = game:GetService("Players")
playerz.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(Char)
Char.Archivable = true
local clone = Char:Clone()
local anchorchildren = clone:GetChildren()
for i, child in pairs(anchorchildren) do
if child.ClassName == "Part" then
child.Anchored = true
end
end
local cf = CFrame.new(8.52, 0.5, -27.24) * CFrame.Angles(0, math.rad(-90), 0)
local vpf = player.PlayerGui:WaitForChild("Avatar").PoliceScotlandUniforms.ViewportFrame
clone.Name = player.Name.."CLONED"
clone.Humanoid.DisplayDistanceType = "None"
clone:SetPrimaryPartCFrame(cf)
clone.Parent = vpf
vpf.CharacterCamera.CameraSubject = clone:WaitForChild("HumanoidRootPart")
end)
end)
(On first spawn)
(When a player respawns)