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

How do I check the parts Rotation then remove it?

Asked by 10 years ago

I'm trying to make a wheel where it spins and then right after it's done spinning the script checks the Parts Rotation and if it's between 10-20 it removes that part.

if script.Parent.Rotation == Vector3.new(0, (10-20), 0) then
    script.Parent:Remove()
end

1 answer

Log in to vote
0
Answered by
Dominical 215 Moderation Voter
10 years ago

Hi! You made a small mistake. Where it states in your Vector value, (10-20). The script looks at that as a Math problem sort of. The computer is reading it as this:

if script.Parent.Rotation == Vector3.new(0, -10, 0) then
script.Parent:remove()
end

To make it "between" two numbers in a simple way you would use the Greater Than(>) or Less Than(<) Operators. Your script SHOULD look like this:

if script.Parent.Rotation.Y>=10 and script.Parent.Rotation.Y<=20 then
    script.Parent:Remove()
end

Look at example two for some help on understanding.

Ad

Answer this question