How to make a spawn car with part of touching? And deletes car in 20 seconds when not used after spawned car and with a cooldown 30 seconds
You’ll have to modify this script to work with your game, but this is one way to do this.
local deb = false
spawner.Touched:Connect(function(hit)
if deb then return end
local hum = hit.Parent:FindFirstChildOfClass("Humanoid")
if not hum then return end
deb = true
local car -- set this variable to your car's model
local thread = task.delay(20, car.Destroy, car)
car.Seat:GetPropertyChangedSignal("Occupant"):Once(function() -- not sure how your system works but iirc this is how it would work with regular seats
task.cancel(thread)
end)
task.wait(30)
deb = false
end)
Can you modify this script right?
model = script.Parent.Parent.Car
backup = model:clone()
enabled = true
model:Destroy()
function regenerate()
enabled = false
script.Parent.BrickColor = BrickColor.new(26)--Black
model = backup:clone()
model.Parent = game.Workspace
model:makeJoints()
wait(30)--Change this number to change the time in between regenerations via the button, in seconds..
script.Parent.BrickColor = BrickColor.new(104)--Purple
enabled = true
end
function onHit(hit)
if (hit.Parent:FindFirstChild("Humanoid") ~= nil) and (enabled==true) then
regenerate()
end
end
script.Parent.Touched:connect(onHit)
Also, add a script that timer deletion cancels when a player is seated in the car