I know how to make complete rotations for a brick, but how do you make rotations that stop at a certain point and not make the brick rotate fully?
Fully rotating script:
while true do script.Parent.CFrame = script.Parent.CFrame * CFrame.fromEulerAnglesXYZ(0,0.1,0) wait(0.02) end
A recording of what I want to happen:
https://gyazo.com/0fde00cd2028caf9403d45eebd7a4a21
What's happening is that I want the brick to rotate at one position, stop, then rotate back. How would I do that?
Hello,
One problem I noticed in your code is the fact that you are using a "while" loop. The way you are using a while loop makes an endless loop, as you most likely already know. I would recommend using a "for" loop. If you aren't familiar with "for" loops, here's an example:
for i = 1, 10 do --Sets a value and each time it loops it increaseas the value of "i" until it becomes 10, and then stops the loop. Basically makes whatever is between this line and the "end" happen 10 times. print("Hi") wait() end
So, using a "for" loop, your code would look something like this:
for i = 1, 90 do script.Parent.CFrame = script.Parent.CFrame * CFrame.Angles(0, 1, 0) --Notice I used "CFrame.Angles()", which is a newer version of CFrame.fromEulerAnglesXYZ(). CFrame.fromEulerAnglesXYZ() is depreciated, meaning no longer mainly used, and is usually looked down upon. wait() end for i = 1, 90 do --Starting another loop to go back script.Parent.CFrame = script.Parent.CFrame * CFrame.Angles(0, -1, 0) --Backwards(negative) rotation. wait() end
If you need any more help or clarification, feel free to comment.