Hey, there! Basically, I wanted an object to be in a GUI so to be able to do that I used a ViewportFrame, but then when I try to set the ViewportFrame’s current camera to a Camera which I created through a local script it would not set it properly. However, when I play test in studio and go to the ViewportFrame and set the CurrentCamera to the Camera manually it works but through a local script it would not work.
Here is the picture of how I set my ViewportFrame out:
andd here is the little snippet code that is in a local script:
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local ShopDialog = Player:WaitForChild("PlayerGui"):WaitForChild("ShopDialog")
local BlueSmoothie = game.ReplicatedStorage.Items.ViewportItems.BlueSmoothie:Clone()
BlueSmoothie.Parent = ShopDialog:WaitForChild("Frame"):WaitForChild("ViewportFrame")
BlueSmoothie:SetPrimaryPartCFrame(CFrame.new(0, 0, 0))
local Camera = Instance.new("Camera")
Camera.Name = "ViewportCamera"
Camera.Parent = ShopDialog:WaitForChild("Frame"):WaitForChild("ViewportFrame")
Camera.CFrame = CFrame.new(Camera.Parent.BlueSmoothie.Main.Position + Vector3.new(0, 10, 20), Camera.Parent.BlueSmoothie.Main.CFrame)
wait(5)
script.Parent.CurrentCamera = script.Parent:WaitForChild("ViewportCamera")