I have a flip car script and it lifts the car 20 studs and rotates it upright. it works fine in theory, but due to the model’s weird position situation, I seem to be rotated into the ground by several hundred studs. I still end up upright though. When I select the model mid play with move tool on, I can see that It registers the origin point, or position of the model to be where I spawned it in from. Is there a way to move the origin point with an unanchored model? because it ruins the orientation of the flipping.
This is the script I use to flip the car.
game.ReplicatedStorage.Flip.OnServerEvent:Connect(function(player: Player)
local Model = player.Character.Humanoid.SeatPart.Parent.Parent
local CarBase = Model["Car Base"].CarBase
local AngleX = -(CarBase.Orientation.X/20)
local AngleZ = -(CarBase.Orientation.Z/20)
for i = 1,20 do
task.wait()
--CarBase.Orientation += Vector3.new(AngleX, 0, AngleZ) < this was a previous attempt to orient the car, ignore it.
Model:PivotTo(Model:GetPivot() * CFrame.Angles(math.rad(AngleX), 0, math.rad(AngleZ)))
Model["Car Base"]:PivotTo(Model["Car Base"]:GetPivot() + Vector3.new(0,1,0))
end
end)
Not 100% sure whats wrong with the math but you can “override” the position of a CFrame by subtracting its current position (Vector3) and adding a new one. That might let you work around this.
Can you explain further? The math for rotating and moving works fine, but I just want to know how to counteract the issue where the models actual position is not where the car really is.
If you take a CFrame and subtract its own position, which you get from cf.Position, and add a new position, you will have the same rotation but at the new position. That does what youre describing:
That’s what I thought, but I mainly just want to fix the models position to be inside the car, so it rotates correctly during the flip. would I just take everything out of the model ,change the position, and add it back?