Hello! I am Domderp999, a Professional builder, and knows a little bit of scripting. However, my cars don’t despawn ever. Does anybody have a script that I can just put inside of the car, and it will despawn every 500 seconds if a player isn’t sitting in the driver seat?
you can use debris service:
local Car = the car
local DS = game:GetService("DebrisService")
DS:AddItem(Car, 500) -- (Object to destroy, time in seconds to wait)
What this service does is it destroys any object when the specified time has been reached.
But you would have to use a different strategy in your case:
so you would do something like this:
local TimeWait = 500
local Car = --the car
if there is no one sitting in the car seat then
while there is no one sitting in the car seat do
TimeWait = TimeWait - 1
if TimeWait == 0 then
Car:Destroy()
end
elseif the is someone sitting in the seat then
TimeWait = 500
end
1 Like
Thanks! Let me go give it a try.
How do I check if somebody is sitting in the car seat?
you would use:
seat:GetPropertyChangedSignal("Occupant"):Connect(function()
and then put the rest of the code after
Hi, I have the same issue as Domderp999. I was wondering, what part of the car would I put this script into? The seat?
Doesn’t matter as long as you define seat
to the relative object.