Spawning a Vehicle

I’m trying to perfectly spawn a vehicle using a script. Currently it spawns like this:
image

I’m looking for it to spawn like this:

This is my code:

self.Model:SetPrimaryPartCFrame(
		CFrame.new(
			Vector3.new(
				math.abs(Spawn.Orientation.Y) ~= 90 and Spawn.Position.X + (Size.X / 2) or Spawn.Position.X, 
				Spawn.Position.Y + (Size.Y / 2), 
				math.abs(Spawn.Orientation.Y) == 90 and Spawn.Position.Z - (Size.X / 2) or Spawn.Position.Z
			), 
		Vector3.new(Spawn.Spawn.Position.X, Spawn.Position.Y + (Size.Y / 2), Spawn.Spawn.Position.Z))
	)

How would I achieve this? There are multiple spawners with different rotations.

1 Like

What I would do is create a part in the Center of vehicle and have it set as the PrimaryPart. Then if the vehicle is welded to that part, have the PrimaryPart CFrame set to the spawn place but add the height off the ground.

local y = 10

self.Model:SetPrimaryPartCFrame(Spawn.CFrame * CFrame.new(0, y, 0))
1 Like

After messing around, I decided that I would find the distance from the current PrimaryPart to the center as for some reason the scripts revolved around the seat being the PrimaryPart. I did basically the same thing you said. :slight_smile:

1 Like