I want to make a character display in the middle of the GUI. I used viewport in this tutorial and here is the code
local vpf = script.Parent:WaitForChild("CharacterVPF")
local char = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
char.Archivable = true
local cam = Instance.new("Camera")
cam.Parent = vpf
vpf.CurrentCamera = cam
local clonedChar
game:GetService("RunService").RenderStepped:Connect(function()
if clonedChar then clonedChar:Destroy() end
clonedChar = char:Clone()
local hrp = clonedChar:WaitForChild("HumanoidRootPart")
cam.CFrame = CFrame.new(hrp.Position + (hrp.CFrame.LookVector * 5), hrp.Position)
clonedChar.Parent = vpf
end)
THIS CODE IS NOT MINE
How do I make one that doesn’t mess with the Viewmodel? By messing with the viewmodel i mean when the viewmodel is activated, it got cloned a lot of time as long as the viewmodel is activated
Why Exactly are you using a RenderStepped? You just need to do that thing once and RenderStepped means you’re constantly updating something (in this case, you’re doing everything again and again forever)
local vpf = script.Parent:WaitForChild("CharacterVPF")
local char = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
char.Archivable = true
local cam = Instance.new("Camera")
cam.Parent = vpf
vpf.CurrentCamera = cam
local clonedChar
if clonedChar then clonedChar:Destroy() end
clonedChar = char:Clone()
local hrp = clonedChar:WaitForChild("HumanoidRootPart")
cam.CFrame = CFrame.new(hrp.Position + (hrp.CFrame.LookVector * 5), hrp.Position)
clonedChar.Parent = vpf
--> REMOVE THIS
--game:GetService("RunService").RenderStepped:Connect(function()
--end)
That is because you’re probably not getting character itself. Print cloned character and you’ll get nil.
To fix, when you’re first trying to get character do:
local Character = player.Character or player.CharacterAdded:Wait()
Your error means that you’re not properly referencing the HumanoidRootPart
Your last error is because you’re trying to find something called Running in your code, you tell me