I have this script here for a localscript, but I have no idea why this isn’t working as intended?
Can someone tell me the reason to why?
local ViewportPart = Instance.new("ScreenGui")
local Main = Instance.new("Frame")
local Port = Instance.new("ViewportFrame")
local UIAspectRatioConstraint = Instance.new("UIAspectRatioConstraint")
ViewportPart.Name = "ViewportPart"
ViewportPart.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")
Main.Name = "Main"
Main.Parent = ViewportPart
Main.AnchorPoint = Vector2.new(0.5, 0.5)
Main.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
Main.BackgroundTransparency = 0.500
Main.BorderSizePixel = 0
Main.Position = UDim2.new(0.5, 0, 0.5, 0)
Main.Size = UDim2.new(0, 159, 0, 159)
Port.BackgroundTransparency = 1.000
Port.AnchorPoint = Vector2.new(0.5, 0.5)
Port.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
Port.BorderSizePixel = 0
Port.BorderColor3 = Color3.fromRGB(27, 42, 53)
Port.Name = "Port"
Port.Parent = Main
Port.Position = UDim2.new(0.5, 0, 0.5, 0)
Port.ZIndex = 1
UIAspectRatioConstraint.Parent = Port
local viewportcamera = Instance.new("Camera",Port)
viewportcamera.CameraType = Enum.CameraType.Scriptable
local yintager = .4
local xintager = 2
local r = 0
local item = Instance.new("Model")
local itempart = Instance.new("Part",item)
item.PrimaryPart = itempart
local viewportpoint = Vector3.new(0,0,0)
local viewportframe = Port
viewportframe.CurrentCamera = viewportcamera
item:SetPrimaryPartCFrame(CFrame.new(viewportpoint))
item.Parent = viewportframe
game:GetService("RunService").RenderStepped:Connect(function()
local cfrane, size = item:GetBoundingBox()
local max = math.max(size.X,size.Y,size.Z)
local distance = (max/math.tan(math.rad(viewportcamera.FieldOfView))) * xintager
local currentdistance = (max/2) + distance
viewportcamera.CFrame = CFrame.Angles(0,math.rad(r),0) * CFrame.new(viewportpoint + Vector3.new(0,(currentdistance*yintager),currentdistance),viewportpoint)
r = r +1
end)
print("Spinning part thing")