In the itemviewportframe it shows a blank instead of the players character
Its a Child of the itemviewportframe and the code is in a local script:
local thePlayer = game.Players.LocalPlayer --Get the player
thePlayer.Character.Archivable = true --Make sure we can clone the character
newCamera = Instance.new('Camera') --Make a new camera
newCamera.CameraType = Enum.CameraType.Scriptable
script.Parent.CurrentCamera = newCamera --Set the viewport to use that camera
local vector1 = Vector3.new(0, -0.5, 7) --This is how far away the camera is away from the character, I like these settings the most.
local vector2 = Vector3.new(100, 3.142, 23) --Without this variable, we'd be staring at the back of the character's head. So we take 180 degrees and turn it into radians
local function addcfv3(a, b)
local x, y, z, m11, m12, m13, m21, m22, m23, m31, m32, m33 = a:components()
return CFrame.new(x + b.x, y + b.y, z + b.z, m11, m12, m13, m21, m22, m23, m31, m32, m33);
end
local RunService = game:GetService("RunService")
RunService.Heartbeat:Connect(function()
if thePlayer.Character:FindFirstChild("HumanoidRootPart") then --Check if there's a HumanoidRootPart
for i, descendant in ipairs(script.Parent:GetDescendants()) do --Get all the parts already in the viewport...
if descendant.ClassName ~= "LocalScript" then -- ... check if it's not the LocalScript ...
descendant:Destroy() -- ... And destroy it, so we can put the new stuff in.
end
end
--This whole area is pretty neat, in that it gets the average of all the part positions. This reduces jittery motion by a lot
local targetedVector3 = Vector3.new()
local totalDivide = 1
for i, component in ipairs(thePlayer.Character:GetDescendants()) do
if component:IsA("BasePart") then
totalDivide = totalDivide + 0.97
targetedVector3 = targetedVector3 + component.Position
end
end
targetedVector3 = targetedVector3/totalDivide
--Finally, we set the camera to our desired position
newCamera.CoordinateFrame = addcfv3(
CFrame.new(
Vector3.new(),
thePlayer.Character.HumanoidRootPart.CFrame.LookVector
),
targetedVector3
)
local me = thePlayer.Character:Clone() --And clone your character into the viewport.
--me.Sound:Destroy() --(Yeah, there's a sound here, delete it otherwise you get an error)
me.Parent = script.Parent
end
end)