Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Making a part spin without jerking around?

In my game, i have a part which i want to spin around, only problem is, i don't know how to do it. This is what i've tried doing:

while wait() do
	script.Parent.CFrame = script.Parent.CFrame * CFrame.Angles(0, Orientation, 0)
	if Orientation == 360 then
		Orientation = 0
	end
	Orientation = Orientation + 1
	wait(0.05)
end

All it does is it makes it spin around, but at increments of over 100 degrees instead of 1 degree, i tried making the wait time slower but that doesn't change the jerky spinning problem, it only makes it jerk around at a slower rate.

4 comments

1

while true do

0

while true do and while wait() do both make infinite loops

0

Ye but wait() only works because it returns the time waited and something else. while true do is not only more expressive it is th proper way to make an infinite loop

0

but using while true, the game can easily glitch out and freeze but using while wait() makes the game wait a tiny bit before executing the script again making it less possible to freeze the game.

1 answer

✓ Accepted answer

Try this:

local part = script.Parent

game:GetService("RunService").Stepped:Connect(function(dt) if (part) then part.CFrame = part.CFrame * CFrame.Angles(0, (math.rad(dt - tick())%60), 0) end end)

3 comments

0

it works perfectly but is there a way to slow it down?

0

Yeah, sorry! try to replace math.rad(dt - tick()) with (math.rad(dt - tick())%60) it should slow it down

0

its even faster now for some reason

This discussion is preserved as it was. New answers, comments, and votes are closed.