Something immediately apparent is you are setting the parent of instances before setting properties:
local VPFcam = Instance.new("Camera")
VPFcam.Parent = accessoryViewport
VPFcam.CFrame = CFrame.new(0, 0, 0)
This is bad practice, you should always set properties before parenting an instance. This post into more detail and explains it better than I could as to why we do this:
I’ve discovered a pretty bad performance issue in one of top games that has to do with Instance.new and wanted to write about this, since this is not obvious unless you know the system inside out.
Tthere are several ways to create a ROBLOX object in Lua:
local obj = Instance.new(‘type’); fill obj fields
local obj = Instance.new(‘type’, parent); fill obj fields
local obj = util.Create(‘type’, { field1 = value1, … })
If you care at all about performance, please only use the first option - I wi…