Hi, I’m currently making a Vehicle crash script for my Aircrafts and I have an issue where the audio plays before it ends.
This is the code I used for my Aircrafts:
Hitbox.Touched:Connect(function(hit)
if Seat.Velocity.Magnitude >= 80 and hit then
ImpactSoundSmall:Play()
ImpactSoundBig:Play()
ExplosionSmall:Emit(150)
ExplosionBig:Emit(150)
for i, part in pairs(script.Parent.Parent.Aircraft:GetChildren()) do
part.Material = Enum.Material.Sandstone
part.BrickColor = BrickColor.new("Dark stone grey")
end
end
end)
And this is what happened:
I tried using :Destroy() after but it still repeats so I’m trying to find an alternative.
local db = false
Hitbox.Touched:Connect(function(hit)
if Seat.Velocity.Magnitude >= 80 and hit then
if not db then
db = true
ImpactSoundSmall:Play()
ImpactSoundBig:Play()
ExplosionSmall:Emit(150)
ExplosionBig:Emit(150)
for i, part in pairs(script.Parent.Parent.Aircraft:GetChildren()) do
part.Material = Enum.Material.Sandstone
part.BrickColor = BrickColor.new("Dark stone grey")
end
task.wait("However much you want until the sound can play again")
db = false
end
end
end)