Vehicle respawn system

Hello! I am trying to make vehicles but after noticing that if a player is on the vehicle and if another player touches the regen block. It deletes the vehicle the other player was on and regens it. I want to make it so if a player is occupying a vehicle it just spawns a new one without deleting the one a player is using.
How can I do this?
Here is a video:

just clone it

it might clump up so

Keep a track of the currently spawned. once the touch event fires
check if the currently spawned is too close. if it is too close then remove it

Is there a variable I use or make to detect if theres already one thats being used?

you can make a table that will contain all the spawned bikes like

Bikes = {motorbike}

and then everytime the respawn is fired. loop over all the bikes and see if they are too close to the spawn area

and when the respawn is fires clone a bike from somewhere and insert it inside the Bikes table
table.insert(Bikes,newmotorbike)

is there a video tutorial or explanation. I started scripting a few months ago but still dont know to much of that level of scripting?

1 Like

this ROBLOX | How to make a auto car spawn - YouTube

but its pretty hefty

1 Like

My guess is you’re not cloning the bike. The best way to do this is make a function that activates a Remote when touching the Part(spawner). Programming on the server to replicate using the :Clone() function and changing the Cloned Bike’s MainPart to the location of the spawn using .Position and Vector3

Links on the Wiki:
Vector3 | Roblox Creator Documentation – Vectors
Oops! – Position
Instance | Roblox Creator Documentation – Cloning
Bindable Events and Functions | Roblox Creator Documentation – Remote functions

If you want more in depth help, please provide examples of the programming used/attempts you made to try to fix this problem. Remember, this isn’t a request site. Always try to attempt things before hand!!
:slight_smile:

2 Likes