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

I need help fixing my rotating cube because it's broken, can you help?

Asked by
fardxD 9
4 years ago

Basically, I was trying to make a rotating cube. It's broken, though. So I used a while true do loop to change the Vector3 of the cube, being the Orientation value (of course) So here is my code.

while true do
wait()
script.Parent.Orientation = script.Parent.Orientation + Vector3.new(0.5, 0.5, 0.5)
end

A video demonstrating this can be found here. https://youtu.be/jhMEZTd_9H4

2 answers

Log in to vote
1
Answered by 4 years ago

If you're planning to change the part's orientation, then use CFrame instead of Vector3. I think the main issue is that the orientation reaches its maximum orientation, and it can't go further.

while true do
    wait()
    script.Parent.CFrame = script.Parent.CFrame * CFrame.Angles(math.rad(1),math.rad(1),math.rad(1)) --Adjust the X, Y, Z values to what suits you. Make sure it's in degrees or radians if you delete the math.rad() part.
end

math.rad() just allows you to convert from degrees into radians. I haven't tested this out, so if there is problems, please leave a comment.

Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago
while true do
    wait(0.03) -- We need this so it wont spin reeeeaaaaly fast
    script.Parent.Orientation = script.Parent.Orientation + Vector3.new(0.5, 0.5, 0.5) -- sloow
        if script.Parent.Orientation == Vector3.new(255,255,255) then
              script.Parent.Orientation = Vector3.new(0,0,0)
        end
end
0
Let me add something on, I want this cube to spin forever. Sorry for not including this in the post. fardxD 9 — 4y
0
It does because it is a while true do statement FunctionalMetatable 490 — 4y
0
@Paladior I updated the script now, it should work infinitely now :D FunctionalMetatable 490 — 4y

Answer this question