Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make this crash physics script work for my demolition derby cars?

Asked by 6 years ago

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)
0
The original script was made by my friend TinyScripter aka rohanskywalker, so that's why there's the "local id = 1 --Put the ID here" part. TheBeaver101 28 — 6y
0
Remember, you have a backspace button on your keyboard to remove comments. Also, the else statement is not necessary on the Second Damage Mesh script hiimgoodpack 2009 — 6y
0
Why do you hate me so much? I realize that hiim, I just forgot to. Maybe you should actually think before you comment TheBeaver101 28 — 6y
0
Why can't I post a regular comment on your questions anymore? Should I get another account on here to post comments to you? hiimgoodpack 2009 — 6y
0
Try adding a wait(5) on line 19 in Regular Mesh Kulh 125 — 6y

Answer this question