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