How can I make a part rotate one way then rotate another way?

Hi! So im trying to make a part rotate one way then rotate another way (sorry if this is hard to understand). What im trying to do is in the vid:

this is what I have right now but it just makes completely rotate forever
,lua
local rButterfly = script.Parent

while true do
rButterfly.Orientation += Vector3.new(0,4,0)
wait()
end
,

In your case, you’re trying to rotate it 45 degrees than 90 degrees than 90 again.

rButterfly.CFrame *= CFrame.Angles(0, math.rad(45), 0) --Initally starts it at the first rotate point.

while wait() do
    for i=1, 90 do
        rButterfly.CFrame *= CFrame.Angles(0, math.rad(1), 0) --Rotates the Butterfly wing
    end
    for i=1, 90 do
        rButterfly.CFrame *= CFrame.Angles(0, math.rad(-1), 0) --Rotates the Butterfly wing the OTHER way
    end
end
1 Like

its not working its still going 360

Try this :wink:

rButterfly.CFrame *= CFrame.Angles(0, math.rad(45), 0) --Initally starts it at the first rotate point.

while wait() do
	for i=1, 90 do
		rButterfly.CFrame *= CFrame.Angles(0, math.rad(1), 0) --Rotates the Butterfly wing
		wait()
	end
	
	task.wait(0.25)
	
	for i=1, 90 do
		rButterfly.CFrame *= CFrame.Angles(0, math.rad(-1), 0) --Rotates the Butterfly wing the OTHER way
		wait()
	end
end

I added wait() in each for loop so it does not run instantly on each run through.

2 Likes

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