How to render viewports?

I have a script that renders based of a camera position. I used viewports for this, but im not sure one a few things, How would I render users, with their clothing and accessories and make the viewport only re-render if the camera cframe changes or a player has moved. This is so that it reduces lag.

These are the file:
image

This is the localscript for the cams:

if not game:IsLoaded() then
	game.Loaded:Wait()
end
script.Parent.Adornee = script.Parent.Adornee.Value
local camera = Instance.new("Camera")
camera.Parent = script.Parent
script.Parent.Viewport.CurrentCamera = camera

coroutine.resume(coroutine.create(function()
	while task.wait() do
		if camera.CFrame ~= script.Parent.Camera.Value.CFrame then
			camera.CFrame = script.Parent.Camera.Value.CFrame
		end
	end
end))


local render = {}
function fixrender()
	table.clear(render) 
	for i,v in pairs(script.Parent.Viewport.WorldModel:GetDescendants()) do 
		if v:IsA("BasePart") or v:IsA("Model") then 
			v:Destroy() 
		end 
	end
	for i,v in pairs(workspace:GetDescendants()) do
		if v:IsA("BasePart") and not v:IsA("Terrain") then
			render[i] = v
			local part = render[i]:Clone()
			part.Anchored = true
			part.Parent = script.Parent.Viewport.WorldModel
			coroutine.resume(coroutine.create(function()
				while part:IsDescendantOf(game) do
					part.Size = render[i].Size
					part.CFrame = render[i].CFrame
					part.Color = render[i].Color
					part.Transparency = render[i].Transparency
					part.Material = render[i].Material
					part.Reflectance = render[i].Reflectance
					game:GetService("RunService").RenderStepped:Wait()
				end
			end))
		end
	end
end

spawn(function()
	while task.wait() do
		fixrender()
		wait(60)
	end
end)

Unless you are updating the contents of the ViewportFrame or resizing the ViewportFrame, it’ll be rendered once and used as an image.

I worded it wrong, its not really am image as it is updated. It is essentially a live feed.

And unless anything changes the ViewportFrame won’t re-render and will use an older frame for better performance?

Which, from what I can tell, is exactly what you want?

Basicly i only want the viewport to render if the camera position has changed or if a player has moved to minimise the amount of times the viewport has to rerender

That already happens automatically.

I’ve literally been telling you that. You don’t need to write any code because ROBLOX DOES IT FOR YOU.

roblox renders non stop which lags

The first reply I sent literally 15 minutes ago quotes a STAFF MEMBER saying that ViewportFrames don’t render unless the content changes.

Roblox themselves have said that ViewportFrames automatically do not render unless their contents change.

Is my script wrong then? Do I need to change it so it doesn’t render?

What the other dude is trying to say is that it wont refresh unless something in the viewportframe changes.

I have no idea what the script is even trying to do, because you can’t force a ViewportFrame to render unless you make an update to it’s contents, but you don’t need the script for what you are trying to do. Roblox does it for you. You don’t need to do anything.

Can you tell me how to set up a viewport correctly? where i dont have to render it?

Listen, I have no idea if you’re trolling or something, but I’ve literally been telling you,

YOU DON’T NEED TO DO ANYTHING AT ALL

Just read my replies if you don’t understand. I’ve made it as clear as possible.

I still don’t understand…
Also their documentation is not helpful. I’m not rendering one item, I’m rendering the entire workspace.
image
ViewportFrame GUI