Viewport Frame Teleporting Player After Being Parented to Surface GUI

I have a photo system in my game and I want the last photo you took to be visible on the your photo camera using a surface gui. I have a folder of photos (viewport frames) under replicated storage, and I have my code find the most recent one, then store it in the variable photo
Here’s the relevant code:

photo = photo:Clone()
photo.Parent = gui
photo.Size = UDim2.new(1,0,1,0)
photo.AnchorPoint = Vector2.new(0.5,0.5)
photo.Position = UDim2.new(0.5,0,0.5,0)

After running this and having it clone the photo to put on my camera, I got teleported to a random location on my map. I tried commenting out the photo.Parent = gui part, and this fixed it, however now I cant see my photo. Why is this happening?

Thanks in advance!

1 Like

I fixed it. It seems there is a bug with roblox where if you try to parent a viewport frame into workspace, for a second, all the parts inside it have collision, and if your character is colliding with it, it may have some strange results. I fixed it by putting the viewport frame in playerGui and setting the adornee instead of just parenting it to the part it should appear on.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.