So this will be hard to explain what I am trying to do, but I will try my best.
Whenever a player spawns a car, the car spawns at a spawning spot, however, if that player does not drive that car away from the spawning spot and a different player decides to spawn a car, it would spawn that same car in the same place as the other car, but it would glitch into that car, making it un-drivable until one of the players leaves the game.
What I am trying to do is get the car deleted after a player spawns a car.
What you could do is make it so there’s a part that’s over the whole space the car spawns, and have it so if a Car is currently touching it, then it will wait a certain number you want it to stay there, then you could check if it’s still touching after the wait time, then if it is, get the car that’s touching then destroy it.
You can also incorporate it when another player spawns a car, then when they try spawning, it will check if a car is there then delete it.
If you check the script that I sent to the other guy, it should show that there is a chance it won’t work. It change the car name to - player.name…“Car1”.
If you could or want to change the script a bit to get it to function like that, that’d be great and may lend you a bit of robux?
You can try make a Folder in Workspace called “Vehicles”, then make it so the clones get parented to there. Then make a part that covers the space that cars get spawned.
Then you can use this script whenever checking if there is a car there.
local checkingPart = game.Workspace.CheckingPart
local checkingFolder = game.Workspace.Vehicles
local waitTime = 15
checkingPart.Touched:Connect(function(partTouching)
wait(waitTime)
if partTouching.Parent == checkingFolder then
partTouching:Destroy()
else
print(“Part Touching Isn’t A Valid Vehicle.”)
end
end)
Please be aware that I am actually writing this on my phone and unable to test in studio so expect something to not work…
This script should only be run in Server side scripts so everyone gets the affect.
I created a regen script that will detect if the model is in bounds of the regen range. If it is, then it will refuse to spawn the object. Much like what @aswdgsagdb said, but with position magnitude instead (since it is more performant and reliable since touching parts don’t replicate from the client to the server).