Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Making a part spin without jerking around?

Asked by 5 years ago

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.

1
while true do User#19524 175 — 5y
0
while true do and while wait() do both make infinite loops 20002000sa 83 — 5y
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 User#19524 175 — 5y
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. 20002000sa 83 — 5y

1 answer

Log in to vote
0
Answered by
F_F 53
5 years ago
Edited 5 years ago

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)

0
it works perfectly but is there a way to slow it down? 20002000sa 83 — 5y
0
Yeah, sorry! try to replace math.rad(dt - tick()) with (math.rad(dt - tick())%60) it should slow it down F_F 53 — 5y
0
its even faster now for some reason 20002000sa 83 — 5y
Ad

Answer this question