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

How would I change this part's rotation using a Vector3Value?

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
1
Answered by
trogyssy 221 Moderation Voter
10 years ago
while true do
wait(0)--The minimum wait is roughly 0.15, putting wait(0) will last one frame, the shortest possible time. wait() is twice that time
if script.Parent.Value ~= script.Parent.Parent.Rotation then
script.Parent.Parent.CFrame=script.Parent.Parent.CFrame*CFrame.Angles(math.rad(script.Parent.Value.X), math.rad(script.Parent.Value.Y), math.rad(script.Parent.Value.Z)) script.Parent.Value
    end
script.Parent.Parent.Changed:wait()--Lessens lag a bit by only making the script run when a property of the parent's parent changes
end

Ad

Answer this question