I used this code to put a single part on a surfacegui and it worked:
local viewportFrame = Instance.new("ViewportFrame") viewportFrame.Size = UDim2.new(1, 0, 1, 0) viewportFrame.Position = UDim2.new(0, 0, 0, 0) 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.CardFrame.Element.Picture 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)
but once i put a model in the viewport, it wont work.
local viewportFrame = Instance.new("ViewportFrame") viewportFrame.Size = UDim2.new(1, 0, 1, 0) viewportFrame.Position = UDim2.new(0, 0, 0, 0) 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.CardFrame.Element.Picture --local part = Instance.new("Part") local part = game.Workspace.Dummy:Clone() --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.Head.Position)
does anyone know what i did wrong ?
i solved the problem, it seems that i made a problem on line 20.
viewportCamera.CFrame = CFrame.new(Vector3.new(0,2,12), part.Head.Position)
I changed it to:
viewportCamera.CFrame = CFrame.new(part.Head.Position + Vector3.new(0,2,12), part.Head.Position)