How do I make this crash physics script work? Basically I am doing crash physics for a demo derby car, and right now I'm working on the back end. I can get it to go to the first damage mesh, but I can't get it so that it waits 5 seconds or somewhere around there before the next mesh can get damaged. If I don't have a time in there before the second damage mesh can break, then it will just break on the first hit. Please help!
I have three meshes, the regular mesh/undamaged back end, the 1st damage mesh (BD1), and the 2nd damage mesh (BD2)
Regular Mesh
local DentSpeed = 40 local id = 1 --Put the ID here script.Parent.Touched:Connect(function(part) if part.Parent == script.Parent.Parent then wait() else end local Seat = script.Parent.Parent.VehicleSeat if Seat.Velocity.Magnitude >= DentSpeed then script.Parent.Transparency = 1 script.Parent.CanCollide = false script.Parent.Parent.BD1.Transparency = 0 script.Parent.Parent.BD1.CanCollide = true Seat.Sound.Volume = 2 Seat.Sound.MaxDistance = 1000 Seat.Sound:Play() end end)
First Damage Mesh (BD1)
local DentSpeed = 40 local id = 1 --Put the ID here script.Parent.Touched:Connect(function(part) if part.Parent == script.Parent.Parent then wait() else local Seat = script.Parent.Parent.VehicleSeat if Seat.Velocity.Magnitude >= DentSpeed then script.Parent.Transparency = 0 script.Parent.CanCollide = true Seat.Sound.Volume = 1 Seat.Sound.MaxDistance = 1000 Seat.Sound:Play() wait(5) script.Parent.Parent.BD2.script.Disable = false else end end end)
Second Damage Mesh (BD2)
script.Disable = true local DentSpeed = 40 local id = 1 --Put the ID here script.Parent.Touched:Connect(function(part) if part.Parent == script.Parent.Parent then wait() else end local Seat = script.Parent.Parent.VehicleSeat if Seat.Velocity.Magnitude >= DentSpeed then script.Parent.Parent.BD1.Transparency = 1 script.Parent.Parent.BD1.CanCollide = false script.Parent.Transparency = 0 script.Parent.CanCollide = true Seat.Sound.Volume = 2 Seat.Sound.MaxDistance = 1000 Seat.Sound:Play() end end)