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

Why can't I parent instantiated part into a viewportframe?

Asked by 5 years ago
Edited 5 years ago
local screen = Instance.new("ScreenGui",game:GetService("CoreGui"))
screen.Archivable = false

local vpf = Instance.new("ViewportFrame",screen)
vpf.Size = UDim2.new(1,0,1,0)
vpf.Visible = false
vpf.BackgroundTransparency = 1

local screenCam = Instance.new("Camera",vpf)
local zDist = 100
screenCam.CFrame = CFrame.new(0,0,-zDist)
vpf.CurrentCamera = screenCam
local copyPart = Instance.new("Part")
copyPart.Anchored = true
copyPart.BrickColor = BrickColor.Black()
local squareTable = {}

for i = 1,4 do
    squareTable[i] = copyPart:Clone()
    squareTable[i].Parent = vpf
    print(squareTable[i].Parent.Name)
end


I have this code here where I instantiate 4 parts and parent them to the vpf in a plugin script I am working on. The issue is that the viewport frame looks like it refuses to allow any parts to parent on it. Any work around on this?

0
I think you should really add a wait in that for i loop, You know what i mean! iiClearlyDeveloper 59 — 5y

Answer this question