✓ Accepted answer
Well, I recommend not to use Changed as it will trigger if any property of seat changes. The reason why it is still destroying, maybe when you spawn it, the property of seat might change, which trigger the Destroy command. To fix this, just replace Changed with GetPropertyChangedSignal(). It should look like this :
local car = script.Parent
local seat = script.Parent.VehicleSeat
seat:GetPropertyChangedSignal("Occupant"):Connect(function()
if not seat.Occupant then
wait(20)
if not seat.Occupant then
car:Destroy()
end
end
end)
local onSpawn = tick()
wait(20)
if tick() - onSpawn >= 20 and not seat.Occupant then
if not seat.Occupant then
car:Destroy()
end
end
It will trigger whenever the property mentioned in () changes.
Lemme know if it helps!
2 comments
I think you should have the wait(20) before your if
No nvm.. you need some loop to check all the time if someone suddenly sits down, you don't delete it