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

How would I change the position of this part correctly?

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

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

1 comment

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?

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