Using while true to rotate a mesh, but it just stops suddenly and starts tweaking

Trying to make a kamebeam but when i use a while true to rotate a mesh to add an effect, it does this:


This is the way i want it to rotate:

How do i achieve this effect?

You are most likely using the right code, the problem is probably the “wait” in the loop, which probably lasts too little, to make the same effect. What you can do is:

  • Calculate / input how long you want the object to last for a full rotation (360 Deg <=> 2pi)
  • Now lets use something like 10seconds for a full rotation. What you do, is divide 360/10seconds and you get needed rotation speed
while(true)do
rotation += percentual
task.wait(360/10)

So, with this code, the object will continuously rotate at the specified speed (in this case, a full rotation in 10 seconds) within the while loop. If you want to change the rotation speed, you can adjust the 10 in 360/10 to a different value, and the object will rotate accordingly.

1 thing I would suggest using is the so called: “Tweenservice” to tween each movement

i just did this:

local runservice = game:GetService('RunService')

runservice.Heartbeat:Connect(function()
	workspace.Shockwave2.CFrame *= CFrame.Angles(0, math.rad(23),0)
end)

and it works, thanks though for the reply

1 Like

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