I am using xLegox's 3.0 cart track, and there is one problem, it won't regen! Here is the script.
local cartModel = script.Parent.TrainCart:clone() local spawnButton = script.Parent.SpawnButton local origin = script.Parent.Origin local buttonOffColor = BrickColor.new(1007) local buttonOnColor = BrickColor.new(1020) function enable(cart) cart.Parent = game.Workspace cart:MakeJoints() cart.DriveScript.Disabled = false end --returns: is the space to spawn the cart in free? function isFree() local origincf = origin.CFrame local a = (origincf*CFrame.new(-3.5, 1, -5.5)).p local b = (origincf*CFrame.new(3.5, 5, 5.5)).p local ax, ay, az = a.x, a.y, a.z local bx, by, bz = b.x, b.y, b.z if ax > bx then ax, bx = bx, ax end if ay > by then ay, by = by, ay end if az > bz then az, bz = bz, az end local list = game.Workspace:FindPartsInRegion3(Region3.new(Vector3.new(ax, ay, az), Vector3.new(bx, by, bz))) return #list == 0 end --enable the current cart enable(script.Parent.TrainCart) do local debounce = false function doSpawn() if not debounce and isFree() then debounce = true enable(cartModel:clone()) wait(0.1) debounce = false end end end --set up connections spawnButton.Touched:connect(function(obj) local par = obj.Parent if par and par:FindFirstChild("Humanoid") then doSpawn() end end) spawnButton.ClickDetector.MouseClick:connect(doSpawn) --spawnButton.DoSpawn.Receive = doSpawn --requires future updates --show open state while true do wait(0.1) if isFree() then spawnButton.BrickColor = buttonOnColor origin.Fire.Enabled = true else spawnButton.BrickColor = buttonOffColor origin.Fire.Enabled = false end end