I have tried a script, and searched the web. and I found one which almost works. Only the wheels are left. It has the and wheels in a different model, within the entire carmodel. The script is inside of the Vehicle seat inside of the body.
1 | local seat = script.Parent |
2 | local vehicle = seat.Parent |
3 |
4 | while true do |
5 | wait( 10 ) |
6 | if not seat.Occupant then |
7 | vehicle:Destroy() |
8 | end |
9 | end |
is what I have tried, can someone please explain, or fix the issue.
Thanks
Put this script In the car model `` local car = script.parent
wait (20) car:Destroy``
I figured it out, I had 1 parent too little, so it didn't remove the entire model, thanks for the help :)
1 | script.Parent.ChildRemoved:connect( function () |
2 | wait( 10 ) --How long it has to wait before removing |
3 | script.Parent.Parent.Parent:remove() --It is a model inside a model inside a model, so 3 parent |
4 | end ) |
Here is a simple fix! I think you messed up on line 6. A lot of people like to do if statements when values are true and false like "if not true then" but I like to do it like "if value ~= true then"
1 | local vehicle = script.Parent |
2 | local seat = script.Parent.Seat |
3 |
4 | while true do |
5 | wait( 10 ) |
6 | if seat.Occupant = = nil then |
7 | vehicle:Destroy() |
8 | end |
9 | end |
This is a server script inside of a model.
Enjoy!