My problem is that when I go into my taxi, it explodes. I know it’s because of the script in it but I don’t know how to prevent it
Code:
local db = false
local cln = script.Parent:Clone()
local Mag = 10 -- How much speed the car has to be going in order to impact
local ImpactSound = "rbxassetid://" .. 9116673678
local CrashSound = "rbxassetid://" .. 9120368953
local BlowUpSound = "rbxassetid://" .. 9116673678
local FireSound = "rbxassetid://" .. 9068935533
local DamageTakenOnHit = 5 -- How much damage humanoids take on hit
local VehicleSeat = script.Parent.Parent.DontDeleteOrBreak.VehicleSeat -- Set this to where your vehicleseat is
local RollOffMax = 500 -- Sound
local RollOffMin = 100 -- SOund
local TimeUntilAnotherImpactCanHappen = .05
local HealthUntilSmoke = 30
local HealthUntilFire = 20
--// Impact sound
local soundD = Instance.new("Sound")
soundD.SoundId = ImpactSound
soundD.Parent = script.Parent
soundD.RollOffMaxDistance = RollOffMax
soundD.RollOffMinDistance = RollOffMin
local sound1 = soundD:Clone()
--// Crash Sound
local soundF = Instance.new("Sound")
soundF.SoundId = CrashSound
soundF.Parent = script.Parent
soundF.RollOffMaxDistance = RollOffMax
soundF.RollOffMinDistance = RollOffMin
local sound2 = soundF
--// Blow up sound
local soundG = Instance.new("Sound")
soundG.SoundId = BlowUpSound
soundG.Parent = script.Parent
soundG.RollOffMaxDistance = RollOffMax
soundG.RollOffMinDistance = RollOffMin
local sound3 = soundG
--// Fire sound
local soundE = Instance.new("Sound")
soundE.SoundId = FireSound
soundE.Parent = script.Parent
soundE.RollOffMaxDistance = RollOffMax
soundE.RollOffMinDistance = RollOffMin
local sound4 = soundE
--// Other
local SRN = false
local OFRN = false
script.Parent.Touched:Connect(function(hit)
if db == false then
db = true
if VehicleSeat.Throttle == 1 or VehicleSeat.Throttle == -1 then
if hit.Parent:FindFirstChild("Humanoid") then
hit.Parent.Humanoid.Sit = true
hit.Parent.Humanoid:TakeDamage(DamageTakenOnHit)
script.Parent.Health.Value = script.Parent.Health.Value - .1
local sound11 = sound1:Clone()
sound11.Parent = script.Parent
sound11:Play()
game.Debris:AddItem(sound11,sound11.TimeLength)
end
if hit.Anchored == false and not hit.Parent:FindFirstChild("Humanoid") then
script.Parent.Health.Value = script.Parent.Health.Value - hit.Mass * 1/25
local sound11 = sound1:Clone()
sound11.Parent = script.Parent
sound11:Play()
end
end
wait(TimeUntilAnotherImpactCanHappen)
db = false
end
end)
script.Parent.Health.Changed:Connect(function(hit)
--// Explode
if script.Parent.Health.Value <= 0 then
local ex = Instance.new("Explosion")
ex.Position = script.Parent.Position
ex.Parent = script.Parent
ex.BlastRadius = 35
script.Parent.Parent.Parent.Parent.ClnScript.the.Value = true
script.Parent.Fire.Enabled = true
script.Parent.Smoke.Enabled = true
local sound33 = sound3:Clone()
sound33.Parent = script.Parent
sound33:Play()
game.Debris:AddItem(sound33,sound33.TimeLength)
game.Debris:AddItem(script.Parent.Parent.Parent.Parent, 15)
cln.Parent = workspace
script.Disabled = true
end
--// Smoke
if script.Parent.Health.Value <= HealthUntilSmoke and SRN == false then
SRN = true
script.Parent.Smoke.Enabled = true
sound2:Play()
end
--// Fire
if script.Parent.Health.Value <= HealthUntilFire and OFRN == false then
OFRN = true
script.Parent.Fire.Enabled = true
wait(10)
local ex = Instance.new("Explosion")
ex.Position = script.Parent.Position
ex.Parent = script.Parent
ex.BlastRadius = 35
script.Parent.Parent.Parent.Parent.ClnScript.the.Value = true
local sound44 = sound4:Clone()
sound44.Parent = script.Parent
sound44.Playing = true
sound44.Looped = true
end
if not script.Parent:FindFirstChild("WeldConstraint") then
script.Parent.Health.Value = 0
end
end)
Video: