To be more specific, I don't want it to just float (i could use BodyPosition) but I also need it only to float on the Y-axis but keep updating its X and Z axis. Which means that if the object moves to the right it won't immediately move back to the last position. I've tried this:
script.Parent.Changed:Connect(function() local XPosition = script.Parent.Position.X local ZPosition = script.Parent.Position.Z script.Parent.Position = Vector3.new(XPosition, 13.376, ZPosition) end)
and it didn't work
CFrame
is a data type that represents the part's position and orientation (rotation).
local part = workspace.Part part.CFrame = CFrame.new(0,10,0) --Moves part to 0, 10, 0. wait(3) part.CFrame = part.CFrame * CFrame.Angles(math.rad(45), math.rad(45), 0) --Same position, change the rotation.
Any parts connected by welds or other attachments will all move as one unit when you change the CFrame of one of the parts. You can use this with your welded parts to move them all as one. Just note that the part you're moving is going to act as the "center" of everything you're moving. If you move a part on the way right and change the CFrame of that, the part on the way right will be teleported to that position and orientation. All the other parts connected will move in relation to part on the right.
You can anchor all your parts now and they will still move together. No body movers needed.
script.Parent.Changed:Connect(function() local XPosition = script.Parent.Position.X local ZPosition = script.Parent.Position.Z script.Parent.CFrame = CFrame.new(XPosition, 13.376, ZPosition) end)
Hope it helps!