I’m attempting to create a viewportframe in which provides the user’s character, but it doesn’t seem to rotate when it’s intended to - staying at its position, only facing at a side. What’s the concurrent issue here? Here’s the my code:
--[ Variables
local ui = script.Parent
local viewport = ui:WaitForChild("ViewportFrame")
--[ Setup
local viewportCamera = Instance.new("Camera", script)
local model = viewport:WaitForChild(" ")
model.PrimaryPart = model.HumanoidRootPart
local viewportPoint = Vector3.new(0, 0, 0)
viewport.CurrentCamera = viewportCamera
model:SetPrimaryPartCFrame(CFrame.new(viewportPoint))
game:GetService("RunService").RenderStepped:Connect(function()
local cframe, size = model:GetBoundingBox()
local maxSize = math.max(size.X, size.Y, size.Z)
local distance = (maxSize/math.tan(math.rad(viewportCamera.FieldOfView))) * 1.5
local currentDistance = (maxSize/2) + distance
local rotationSet = 0
-- I'm assuming that this line underneath doesn't function, but I don't acknowledge why
viewportCamera.CFrame = CFrame.Angles(0, math.rad(rotationSet), 0) * CFrame.new(viewportPoint + Vector3.new(0, 0, currentDistance), viewportPoint)
rotationSet = rotationSet + 1
end)