Can someone tell me why this isn't working?

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")

i think i believe the PlayerGui spawns more quicker than the script itself since it is one of the core components

I don’t think so, I tried adding a delay but still nothing.

what does the output sussily say

Is this in a local script? game.Players.LocalPlayer is only accessible through a local script.

Yeah, this is inside a localscript.

Literally nothing at all, which doesn’t help me much.

If you put this script as a localscript in the startergui then it will create the screengui and frame. You can’t create things into the playergui from the localplayer so if you have a way of getting the player the you don’t have to put it in the startergui. Then again, you have to use another way to get the playergui other than localplayer.

Edit - I deleted the script below because when you put it in a script in Roblox it would show up as wrong because the “” showed as wrong.

Unfortunately this still hasn’t fixed the issue I am having.

Is the issue getting the part to spin?

The issue is getting the part to even render into the viewport frame.

It is supposed to look like this:

https://gyazo.com/df1ad3c22cd21c61a9cd7ff82274c9fe

But the outcome is this:

image