Using Debis
(game:GetService('Debris')
, you can achieve exactly that.
local Part = Instance.new('Part', workspace)
game:GetService('Debris'):AddItem(Part, 9) -- Instance, Lifetime (Seconds)
Place .Touched events inside parts likely to be hit, once hit compare it with the 1st parameter which gives you the collided object and see if it was another car, wait a certain amount of time, destroy the model and disconnect the event.
I donโt understand
(30 chars 30 chars yes yes)
Basically there is a service called Debris and itโs used to help clear I guess you could say any loose parts in workspace.
You get the service like this
local Debris = game:GetService("Debris") -- Getting the service "Debris"
local part = game.Workspace.Part -- part we want to get rid of
Debris:AddItem(part, 2) -- After two seconds the part will be gone.
AddItem is the event used by Debris to insert an item into the Debris.
The first agrument is the object, the second one is the length of time until itโs removed.
You could put a script inside the wall that breaks the joints of anything it touches, and then use Debris:AddItem() to remove it after a certain amount of time:
local Debris = game:GetService("Debris")
local wall = script.Parent --assuming that this script is parented under the wall
wall.Touched:Connect(function(hitPart) --hitPart represents the part that touched the wall
hitPart:BreakJoints() --detaches the part from anything it was previously welded/joined to
Debris:AddItem(hitPart, 5) --after 5 seconds, the part will disappear.
end)
ohh thanks.
(30 chars poopy man)