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

Does Viewport frame not work on SurfaceGui?

Asked by 2 years ago

i put this code on a "Script" inside SurfaceGui:

local viewportFrame = Instance.new("ViewportFrame")
viewportFrame.Size = UDim2.new(1, 0, 1, 0)
viewportFrame.Position = UDim2.new(0, 15, 0, 15)
viewportFrame.BackgroundColor3 = Color3.new(0, 0, 0)
viewportFrame.BorderColor3 = Color3.new(0.6, 0.5, 0.4)
viewportFrame.BorderSizePixel = 2
viewportFrame.BackgroundTransparency = 0.25
viewportFrame.Parent = script.Parent
local part = Instance.new("Part")
part.Material = Enum.Material.Concrete
part.BrickColor = BrickColor.new("Bright blue")
part.Position = Vector3.new(0,0,0)
part.Parent = viewportFrame

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

viewportCamera.CFrame = CFrame.new(Vector3.new(0,2,12), part.Position)

it doesn't work.

however when I converted it to "Localscript" and put it on on ScreenGui, it works perfectly fine.

hmm...

1 answer

Log in to vote
0
Answered by 2 years ago

I believe if you put the SurfaceGui into StarterGui and keep the script local, then all you have to do is change the Adornee property of the Gui in order to make this work.

Ad

Answer this question