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

How would I change the position of this part correctly?

Asked by 10 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

I have a part that becomes unanchored. When it becomes anchored, the position isn't the same as before. What I'm trying to do is move the part to the position it was at before, but this script doesn't move it all the way; it's off by about 0.2 studs on at least 1 axis all the time.


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

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

1 answer

Log in to vote
1
Answered by 10 years ago
k = true

while k do
wait(0.01)
    if script.Parent.Value ~= script.Parent.Parent.Position then
    script.Parent.Parent.CFrame = CFrame.new(script.Parent.Value)
    end
end

Don't forget the commas in the IntValue, X, Y, ZAnd this is your lesson, CFrame is ALWAYS used when doing somethings with Position and Rotation

0
Alright, that helped. Now I need to do the same thing but instead of position I need to do rotation, but I don't know how to do that. Could you help me on that? whyOmustOitObeOme 7 — 10y
Ad

Answer this question