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

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

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

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.

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

3 comments

0

Let me add something on, I want this cube to spin forever. Sorry for not including this in the post.

0

It does because it is a while true do statement

0

@Paladior I updated the script now, it should work infinitely now :D

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