Car Spawning Problem

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.

Then check if the car is not nil then spawn it, unless destroy the car then spawn another one.

Also provide a script for us to know the problem in the given.

Hello!

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?

I can try to help.

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.

1 Like

Thanks man, I will now be testing this and yes, I have a folder for all the vehicles and such as.

1 Like

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).

3 Likes

Late response but turned out it was in my draft…

“Could you send it, please? It would help a lot with my game.”

1 Like

Sure. This will soon also be a public resource as well once I update it a little.
SmartRegen.rbxm (10.4 KB)

3 Likes

Thanks. (robloxmaxlimitcharacters)

This works by deleting the car after 15 seconds, doesn’t detect if the car is still touching the part.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.