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

How do I increase the rotation of the Z axis until a certain point?

I am terrible at Vector3 and CFrame so bear with me.

Here's the code I have:

	repeat
		part.Rotation = Vector3.Z(0) + Vector3.Z(-1)
		wait(0.1)
	until
		part.Rotation == Vector3.new(0,45,-180)

What can I replace this code with?

Any answers are greatly appreciated.

3 comments

0

If this is all you're doing, you could do a for loop.

0

I could do a for loop. that's no problem, but I don't know how to call on a specific axis.

0

Consider looking at BodyAngularVelocity

1 answer

✓ Accepted answer

First of all, It's best to use the CFrame property of the part. Try placing a block just under another larger block and change the rotation. You will see what I mean.

I recommend reading this.

This will also be useful

We can use a simple for loop with the lerp method of cframes to easily do this.


-- We use '0, 1' because the percent complete of a CFrame will take a value from 0 to 1.
-- 0 being absolutely no progress and one being complete.
-- in 0, 1, 0.1, '0.1' is what increment to change from. So the loop looks like this.
--[[
	0
	0.1
	0.2
	0.3
	--etc
--]]
for i = 0, 1, 0.1 do
	part.CFrame = part.CFrame:lerp(CFrame.Angles(math.rad(0), math.rad(45), math.rad(180)) * part.CFrame, i)
wait()
end

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