Regen script keeps duplicating the car?

Hello, for some reason my regen script works in studio, but in client it duplicates the car.

model = game.Workspace.Exceed – Change “Compressor” to the name of your model.
new = model:clone()
enabled = true
if enabled then
script.Parent[“Car Ignition Startup”]:Play()
enabled = false
wait(0.3) – This is how long it will take to regen
model = new:clone()
model.Parent = game.Workspace
wait(5) – This is how long it will take for the regen button to be enabled after being used
enabled = true

1 Like

Unsure of what is causing this issue, to properly fix it I think I’d need to do debugging and testing inside of studio, however I can advise that you try :Destroy() rather than :Remove(), and see if that helps. Simply because I believe remove is deprecated.

It would help us a lot to find solution of your problem if you attach your full script.
By the way, you should not use MakeJoints(), it is old and deprecated.

You need a longer wait. And if the car is still there it will cause issues. Before cloning the car you need to make sure the area is clear. An easy solution would be creating a invisible non-collide box and getting touching parts.

local IgnoreList = {-- Add parts to ignore}
local Box = game.workspace.Model.SpawnBox
local TouchingParts = Box:GetTouchingParts()
for i = 1,#TouchingParts do
     if table.find(IgnoreList,TouchingParts[i]) then
          -- Do Nothing
          --Clone Car

I would still recommend adding what I mentioned before. As if a player or another car is where the car is going to spawn then it will cause some issues.

I just noticed that whenever 2 people press the button at the same time, the car gets duplicated. I. don’t. want. this.

Here is an example:
example.rbxl (71.2 KB)

Does anybody have a fix???

ACTUALLY I’m wrong. For some reason the regenerate script only duplicates the car by the amount of players for some odd reason. Is it because the tool is in StarterPack? It works in client with only one player.

Why do I keep getting ignored on most forums?