Viewport frame doesn't update

The items inside of my shop viewport frames no longer update consistently despite working correctly less than a week ago (I haven’t edited this script).


mrad is simply math.rad assigned to a variable.

Instead of spinning constantly as they used to, the property updates correctly in the explorer (indicating that the script is working the same) however the viewport frame doesn’t update accordingly. Sometimes they do actually change (and strangely it happens every time I click to change the UI page despite there being nothing to cause this anywhere in the script) however it’s odd for it to become so jittery and to outright freeze sometimes all of a sudden.

Is there a reason for this I’m not aware of / does it have a fix? My only guess right now is that it’s a bug but I thought I’d try asking here just in case.

The explorer shows the Flashlight in PlayerGui, not StarterGui.

I noticed that roblox recently added a function to ViewportFrame, CaptureSnapshotAsync.

This was around the time you noticed this issue. Maybe Roblox messed something up who knows? I’d go for making a bug report honestly.

I did some work and here is what I did:


local loadedItems = {
	-- Add your item data here
}

local mrad = math.rad -- Assign math.rad to a variable

for itemName, itemObject in pairs(loadedItems) do
	itemObject.viewmodel:PivotTo(CFrame.new(Vector3.new(0, 0, 0), Vector3.new(mrad(30), 0, mrad(30))))

	local function updateRotation()
		itemObject.viewmodel:PivotTo(itemObject.viewmodel:GetPivot() * CFrame.Angles(0, mrad(0.5), 0))
	end

	RunService:BindToRenderStep(
		"SpinnerHook_" .. itemName, Enum.RenderPriority.Camera.Value, function()
			updateRotation()
		end
	)
end

I’ve created a separate updateRotation function to update the rotatio, called in the BindToRenderStep loop. I wish you luck in what you are doing!

Sorry about the really late update here -

I did eventually figure out a solution by ‘jittering’ the FOV of the viewport camera slightly which appears to force the viewport to update.

That’s really interesting. I’ll check that I can consistently repro it, and if I don’t find a definitive solution or a workaround that isn’t weird and hacky I’ll look into making it a bug report.

I did actually try something similar to this previously to no avail - it appears the viewport is only forced to update when either it or its camera have their properties changed and so the FOV was the only workaround that worked for me. Thank you for offering help regardless!

3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.