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

I can't create a camera in my ViewportFrame, why?

Asked by 5 years ago
Edited 5 years ago

When I try to create a camera with my function :GetViewportFrame(), the camera disappears! No error is recorded, I dont understand why the camera "destroys" itself and how to fix it? Because I do not see any error in my function. Instance.new (type, parent) is supposed to work so I dont understand where the error is.

Explorer here

Script

function InstanceGame:VoteTime()
    for i = 1, 3 do -- Set three maps.
        local SurfaceGui = Instance.new('SurfaceGui', MapVoter.System.Screens[i].Screen)
        SurfaceGui.CanvasSize = Vector2.new(260, 400)
        SurfaceGui.Face = 'Right'

        local ViewportFrame = InstanceGame:GetViewportFrame(Map)
        ViewportFrame.Parent = SurfaceGui
    end
end

function InstanceGame:GetViewportFrame(Receive)
    local ViewportFrame = Instance.new('ViewportFrame')
    ViewportFrame.Size = UDim2.new(1, 0, 1, 0)

    local Map = Receive:Clone()
    Map.Parent = ViewportFrame

    local Camera = Instance.new('Camera', ViewportFrame)
    ViewportFrame.CurrentCamera = Camera
    Camera.CFrame = Map.Cinematic.PartA.CFrame

    return ViewportFrame
end
1
i don't think u need to parent the camera to the vpf anyway INOOBE_YT 387 — 5y
0
True, thank you NiniBlackJackQc 1562 — 4y

Answer this question