How can I make an AI car that the player spawns inside of?

I want to make an AI car that:

  1. Doesn’t let you leave the vehicle.
  2. Supports 4 max players.
  3. Drives in a straight line forever until the map ends.
  4. Spawns the player inside of a (available) seat.

Issue is that I have no idea on how to do anything on that list… I can only set the server size to 4 if that’s even close to any of those listed.

I don’t know how to do any of these and I need help on figuring out something since I don’t have a solution.

I will say that this is suppose to be a remade version of ‘late night drive’ (late night drive - Roblox) so if you need extra details you can look in that game. Thanks.

I will assume you have the car model already :slight_smile:

Set the humanoid’s jump power to 0 once they enter the vehicle (write humanoid.UseJumpPower = true first)

Just have 4 seats in the car so no one else can get in (your method works too)

Straight line makes it much easier. Have an attachment and a linear velocity in the car’s primary part (movement part) to move it in a straight line forever. Just destroy the velocity when you reach the end of the map

When the player activates a prompt in the car loop through all the seats and check if they have an occupant, and if they have then skip it. If there isn’t one then seat the player inside it

function GetSeat()
  for _,seat in pairs(workspace.AICar.PassengerSeats:GetChildren()) do
      if seat.Occupant then continue end
      return seat
  end 
  return nil
end 
workspace.AICar.Door.ProximityPrompt.Triggered:Connect(function(player)
   local seat = GetSeat()
   if seat then
      seat:Sit(player.Character.Humanoid)
   end
end)
1 Like

If the interior of the vehicle isn’t important then you don’t even have to spawn the character at all

1 Like

even if it was, i think i would use contextaction service to ignore player input or just clone the player models into the car and change the cameras

1 Like

interior is literally the most important part. look at ‘late night drive’
not to be rude btw

correction:

i meant that they automatically spawn into the car without any things that they need to do to get inside of the car just like ‘late night drive’

but thanks for helping! so far it’s helping right now

function GetSeat()
  for _,seat in pairs(workspace.AICar.PassengerSeats:GetChildren()) do
      if seat.Occupant then continue end
      return seat
  end 
  return nil
end 
game.Players.PlayerAdded:Connect(function(plr)
   local char = plr.Character or plr.CharacterAdded:Wait()
   local seat = GetSeat()
   if seat then
      seat:Sit(char.Humanoid)
   end
end)

I suppose this is what you wanted? Also the seats need to be “Seat” instances

1 Like