This problem occurs (and can be reproduced 100% of the time) in these circumstances:
- A ViewportFrame has children and a camera to view them.
- ViewportFrame.Parent is set to some visible gui object and thus shown on screen, as expected.
- ViewportFrame.Parent is set to
nil
. - Immediately after, the Frame (former parent) is destroyed via
Frame:Destroy()
. Steps 3 and 4 must happen sequentially without yielding between. - ViewportFrame.Parent is set to a new gui object.
ViewportFrame’s contents will now be invisible (the ViewportFrame itself will be visible) until one of its ancestor’s visibility is toggled.
Below I have attached a video of the problem occurring and being fixed by inverting the Visible property. I have also attached the place file used to make the video, the code of interest is located in StarterGui → ScreenGui → LocalScript.
viewportframe_glitch.rbxl (27.2 KB)