Viewport Frame Objects look choppy

I’m making a shop where you can buy kill sounds, but the issue is that the rotating parts look extremely choppy…

How do I fix this?

local list = script.Parent

while task.wait() do
	if #list:GetChildren() ~= 0 then
		for i, v in pairs(list:GetChildren()) do
			if v:IsA("ImageButton") and v.ViewportFrame.ViewportPart.FrontFace:IsA("Decal") then
				v:WaitForChild("ViewportFrame"):WaitForChild("ViewportPart").CFrame *= CFrame.Angles(0, 0.05, 0)
			end
		end
	end
end

2 Likes

task.wait() could be the reason why the rotation looks choppy. I’d recommend using RunService.RenderStepped to rotate the part, like this:

local RunService = game:GetService("RunService")

local part = script.Parent

-- Creates renderstepped loop and rotates the part at 5 studs a second
RunService.RenderStepped:Connect(function(dt)
	part.CFrame *= CFrame.Angles(0, 5 * dt, 0)
end)

The dt variable makes sure the part rotates consistently at different fps. Hope this helps!

2 Likes

Increase your graphics quality, and it will run smooth.
It happens if you have low graphics quality, due to performance issue.

Also I suggest you to use RunService instead.

local list = script.Parent
local speed = 2

local runService = game:GetService("RunService")
runService.RenderStepped:Connect(function(delta)
    if #list:GetChildren() ~= 0 then
        for i, v in pairs(list:GetChildren()) do
            if v:IsA("ImageButton") and v.ViewportFrame.ViewportPart.FrontFace:IsA("Decal") then
                v:WaitForChild("ViewportPart").CFrame *= CFrame.Angles(0, delta*speed, 0)
            end
        end
    end
end)

2 Likes

Bit Insane for my game standards, but I can understand why.

Will Run Service give it any type of boost? And I’m asking this considering my game Is quite literally a game where you break everything.

@Synitx @wastbo

It basically makes no difference. Both task.wait and .Renderstepped will run every single frame, just in different chronological order.

Instead of using a continuous loop to rotate the CFrame, I recommend utilizing tweens for smooth rotations.

2 Likes