Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

char (and therefore sub) is nil?

Asked by 5 years ago
lua
local char = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:wait()

local sub

local viewportFrame = script.Parent.ViewportFrame

local viewportCamera = Instance.new("Camera")
viewportFrame.CurrentCamera = workspace.CurrentCamera
viewportCamera.Parent = workspace

game:GetService("RunService").RenderStepped:Connect(function()
    if sub then
        sub:Destroy()
    end
    sub = char:Clone()
    for i, v in pairs(sub:GetChildren()) do
        if v:isA("BasePart") then
            v.Anchored = true
        end
    end
    sub.Parent = viewportFrame
end)

i get an error that Sub is nil, I substituted char with baseplate and it worked perfectly, so the fact char is nil is the problem. I don't know what in particular I did wrong

0
You cannot clone the character from the start, as its Archivable property is set to False by default theking48989987 2147 — 5y
0
Thanks for this even though it's been nearly a year ago :eyes: ventrixion 27 — 4y

Answer this question