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

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

Asked by
Suamy 68
7 years ago

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.

0
If this is all you're doing, you could do a for loop. awfulszn 394 — 7y
0
I could do a for loop. that's no problem, but I don't know how to call on a specific axis. Suamy 68 — 7y
0
Consider looking at BodyAngularVelocity MrN00bReaper 30 — 7y

1 answer

Log in to vote
1
Answered by
AZDev 590 Moderation Voter
7 years ago
Edited 7 years ago

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
Ad

Answer this question