Hi there!
I have been working on a modded NDS game lately when I noticed something with the meteors disasters. So in NDS, when the meteor collides with the ground, it plays the explosion sound right? But in my game when it collides with the ground, it sometimes doesn’t play the sound. And when it does, if another meteor has collided before the sound has finished, it cuts that sound and starts playing the new one. I’m assuming it’s because the code is old, its probably why it doesn’t work.
Here’s the code for the meteors. Hoping somebody can help ![]()
local function connectMeteorTouched(meteor)
local active = true
local firstHit = true
local function removeMeteor(meteor)
local fire = meteor:FindFirstChild('Fire')
local smoke = meteor:FindFirstChild('Smoke')
if fire and smoke then
fire.Enabled = false
smoke.Enabled = false
end
active = false
meteor.Anchored = true
meteor.Transparency = 1
DebrisService:AddItem(meteor, 3)
end
meteor.Touched:connect(function(hit)
if not active then
return
end
if hit and hit.Parent ~= nil then
if not hit.Anchored then
hit:BreakJoints()
hit.Velocity = meteor.Velocity
end
if firstHit then
firstHit = false
local explosion = Instance.new("Explosion")
explosion.Position = meteor.Position
explosion.BlastPressure = 0
explosion.BlastRadius = 0
explosion.ExplosionType = Enum.ExplosionType.NoCraters
explosion.DestroyJointRadiusPercent = 0
explosion.Parent = meteor
game.Workspace.CamShakeMeteor.Enabled=true
local sound = workspace.Structure:FindFirstChild("ExplosionSound")
if sound ~= nil then
sound:Play()
end
wait(0.2) -- Allows the meteor to dig a hole before expiring
removeMeteor(meteor)
end
end
end)
end
function createMeteor(meteorFolder)
local meteor = meteorTemplate:Clone()
local meteorSize = meteorSizes[math.random(1, #meteorSizes)]
meteor.Size = Vector3.new(meteorSize, meteorSize, meteorSize)
meteor.Position = Vector3.new(math.random(-mapradius/2, mapradius/2), 500, math.random(-mapradius/2, mapradius/2))
meteor.Velocity = Vector3.new(math.random(-100,100), -100, math.random(-100,100))
meteor.CanCollide = false
local randomMeteorSound = oldcontent.Sounds:FindFirstChild("Meteor" ..tostring(math.random(1, 3)))
if randomMeteorSound ~= nil then
-- TODO: Woosh sound
local meteorSound = randomMeteorSound:Clone()
meteorSound.Name = "ExplosionSound"
meteorSound.Parent = workspace.Structure
end
game.Debris:AddItem(meteor, 12)
meteor.Parent = meteorFolder
connectMeteorTouched(meteor)
return meteor
end