Hello, I have a problem with a vehicle spawner. Basically there’s a button and when you touch it, it spawns a vehicle. The only problem is that I don’t want it to spawn if there’s another vehicle blocking the way or is already spawned. Any ideas on what I can do?
Create a boolValue in ServerStorage and whenever a vehicle is within the spawn radius that bool value will become true and if not false. Check whether the space is open via a script to see if the value is true or false.
Add debounce in the script and use region3 to figure out what’s touching that region of the spawn and if it’s part of the vehicle it will set the debounce to true.
Check if there’s a car that is not near the spawner.
Check if there’s a car that spawned from the spawner
Here is an example code :
local carSpawned = false
local nearbyCar = nil
for _, car in pairs(carFolder:GetChildren())
if (spawner.Position - car.Engine.Position).Magnitude < carSize then
nearbyCar = v
if not nearbyCar and not carSpawned then
carSpawned = true