Re-orientating a model messes up the original look of the it

I have a body mover that moves the cart, in sharp turns it rotates sideways. When it comes to a complete stop, I anchor the PrimaryPart, and set the orientation of all the parts X and Z to 0, keeping Y to normal. All the parts are un-achored and connected to the primary part using a WeldConstraint.

Here is the code sample:

cart.Main.Anchored = true
bodyVelocity.Velocity = Vector3.new(0, 0, 0)

-- Wait for 10 seconds before reversing back
wait(3)

for _, parts in pairs(cart:GetChildren()) do
	if parts.Name ~= "Script" then
		parts.Orientation = Vector3.new(0,parts.Orientation.Y,0)
	end
end

Before:
cartbefore.PNG

After a couple of rounds:
bruhs i cry

I tested just rotating the PrimaryPart using Orientation, but only the PrimaryPart would rotate, not the entire model, yet it all Welded with WeldConstraints…

Maybe I’m just taking the wrong approach to this bug…

You have to use CFrame if you want the entire model to move, just using Orientation and Vector3 will not do it.

1 Like

I appreciate it. The CFrame did work. Still don’t understand why the CFrame works, and not orientation with Vector3.

This is the code I used to fix my bug:

local primaryPart = script.Parent.PrimaryPart
local position = primaryPart.Position
local yRotation = primaryPart.Orientation.Y

primaryPart.CFrame = CFrame.new(position) * CFrame.Angles(0, math.rad(yRotation), 0)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.