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

How would I change the rotation of this part?

Asked by 10 years ago

I have a part that becomes unanchored. When it becomes anchored, the rotation isn't the same as before. What I'm trying to do is move the part to the correct rotation it was at before, but the script doesn't get it right all the time (it's off by about 90 degrees or so).

k = true

while k do
wait(0.01)
    if script.Parent.Value ~= script.Parent.Parent.Rotation then -- The script's parent is a Vector3Value which holds the rotation the part will go to and the script's parent's parent is a part.
    script.Parent.Parent.Rotation = script.Parent.Value
    end
end

I checked to make sure the Value is correct, and it is. The value and the part's rotation are still different even if the script is constantly checking if it isn't. Any help on how to move the part perfectly to its correct rotation?

1 answer

Log in to vote
0
Answered by 10 years ago

I don't think that you can set rotation, it should be used as read-only property. Most effective way is CFrame:

k = true


while k do
wait(0.01)
    if script.Parent.Value ~= script.Parent.Parent.Rotation then
    script.Parent.Parent.CFrame = CFrame.new(script.Parent.Parent.Position) * CFrame.Angles(script.Parent.Value)
    end
end
0
The output says "bad argument #3 to 'Angles' (number expected, got no value)" whyOmustOitObeOme 7 — 10y
0
Well then something is wrong with your vector3 variable. ZarsBranchkin 885 — 10y
Ad

Answer this question