My Car Spawner works but it won't delete or anything I tried destroying it, using a part to destroy it, putting a script that is cloned that waits 10 seconds to remove it nothing worked.
It's like roblox "destroy" and "remove" feature is broken.
local RandomCar = math.random(1,4) local Cars = game.ReplicatedStorage.Cars:GetChildren() local debounce = false while true do wait(5) for i,v in pairs(Cars) do local CarClone = v:Clone() CarClone.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") and not debounce then debounce = true hit.Parent.Humanoid.Health = 0 script.HitSound:Play() wait(2) debounce = false end end) if RandomCar == 1 then CarClone.Parent = workspace.CarSpawnFolder CarClone.CFrame = workspace.CarPos1.CFrame while true do wait() for i= 1, 300 do CarClone.CFrame = CarClone.CFrame * CFrame.new(0,0,2) wait() end end wait(10) CarClone:Remove() else if RandomCar == 2 then CarClone.Parent = workspace.CarSpawnFolder CarClone.CFrame = workspace.CarPos2.CFrame while true do wait() for i= 1, 300 do CarClone.CFrame = CarClone.CFrame * CFrame.new(0,0,2) wait() end end wait(10) CarClone:Remove() else if RandomCar == 3 then CarClone.Parent = workspace.CarSpawnFolder CarClone.CFrame = workspace.CarPos1.CFrame while true do wait() for i= 1, 300 do CarClone.CFrame = CarClone.CFrame * CFrame.new(0,0,2) wait() end end wait(10) CarClone:Remove() else if RandomCar == 4 then CarClone.Parent = workspace.CarSpawnFolder CarClone.CFrame = workspace.CarPos2.CFrame while true do wait() for i= 1, 300 do CarClone.CFrame = CarClone.CFrame * CFrame.new(0,0,2) wait() end end wait(10) CarClone:Remove() end end end end end end
Here's the clone script you wanted to see:
system = script.Parent model = system.Station -- backup = model:Clone() regen = system.Regen model:remove() function checkRegen() if regen.Value == 1 then model:remove() wait(1) model = backup:Clone() model.Parent = workspace model:MakeJoints() end end regen.Changed:connect(checkRegen)