Added a fuel and damage system to an AC6 Chassis. The Damage system calculates the damage correctly but fails to activate the 2nd part of the script which kills the vehicle.
https://gyazo.com/e72f3ea13cd6861b108c0fcbb3deba43
The strange part, when you jump out the vehicle and enter it, the script registers the damage.
https://gyazo.com/07c7ac4a7385759fca95028b10ae8ae9
The Script is a Local Script.
wait(.1) local car = script.Parent.Car.Value local dmghandler = car.Body.dmghandler local per = script.Parent.AC6T_Stock_Gauges.dmg.Text wait(.1) function crashed(crash) wait(.1) if dmghandler.Velocity.Magnitude > crash.Velocity.Magnitude + 5 and crash.CanCollide == true or crash.Velocity.Magnitude > dmghandler.Velocity.Magnitude + 5 then script.Disabled = true dmghandler.dmg.Value = dmghandler.dmg.Value - dmghandler.Velocity.Magnitude / 0.4 script.Disabled = false elseif 0 >= dmghandler.dmg.Value then print("Car Dead") script.Disabled = true dmghandler.dmg.Value = 0 script.Parent.Values.Torque.Value = 0 script.Parent.Values.Gear.Value = 0 script.Parent.IsOn.Value = false script.Parent.Dead.Value = true end end dmghandler.Touched:connect(crashed)
Any help is appreciated.
Thanks, Bradolink
You can detect whether or not the player has hit the car. Fix:
wait(.1) local car = script.Parent.Car.Value local dmghandler = car.Body.dmghandler local per = script.Parent.AC6T_Stock_Gauges.dmg.Text wait(.1) function crashed(crash) wait(.1) if dmghandler.Velocity.Magnitude > crash.Velocity.Magnitude + 5 and crash.CanCollide == true or crash.Velocity.Magnitude > dmghandler.Velocity.Magnitude + 5 then script.Disabled = true dmghandler.dmg.Value = dmghandler.dmg.Value - dmghandler.Velocity.Magnitude / 0.4 script.Disabled = false elseif 0 >= dmghandler.dmg.Value then print("Car Dead") script.Disabled = true dmghandler.dmg.Value = 0 script.Parent.Values.Torque.Value = 0 script.Parent.Values.Gear.Value = 0 script.Parent.IsOn.Value = false script.Parent.Dead.Value = true end elseif crash.Parent = game.Players:GetPlayerFromCharacter(crash.Parent) then print("Player touched car, not taking damage") end end dmghandler.Touched:connect(crashed)
-1bitPro