So I have this module script which is used every time a brick is hit with the explosion created. The module fully works for code like a rocket launcher but every time I try to use a bomb to do the same thing the module wont delete the bricks heres both scripts, first is the one in the bomb(disabled) which gets enabled when bomb is placed and second one is the actual module.
local Tool = script.Parent
local Debris = game:GetService("Debris")
local replicatedStorage = game:GetService("ReplicatedStorage")
local explosionModule = require(replicatedStorage.Modules:FindFirstChild("BombExplosionModule"))
local updateInterval = .4
local currentColor = 1
local colors = {26, 21}
local ticksound = Instance.new("Sound")
ticksound.SoundId = "rbxasset://sounds\\clickfast.wav"
ticksound.Parent = script.Parent
function update()
updateInterval = updateInterval * .9
script.Parent.BrickColor = BrickColor.new(colors[currentColor])
currentColor = currentColor + 1
if (currentColor > 2) then currentColor = 1 end
end
function blowUp()
local realResult = tostring(script.Parent.creator.Value)
explosionModule:Explode(realResult, script.Parent.Position, 5)
script.Parent.Transparency = 1
end
while updateInterval > .1 do
wait(updateInterval)
update()
ticksound:play()
end
blowUp()
wait(2)
script.Parent:remove()
local module = {}
local replicatedStorage = game:GetService("ReplicatedStorage")
local collectionService = game:GetService("CollectionService")
local playerScores = replicatedStorage:FindFirstChild("PlayerScores")
local partsHit = {}
function module:Explode(playerName, position, radius)
local explosion = Instance.new("Explosion")
explosion.BlastPressure = 7000
explosion.DestroyJointRadiusPercent = 0
explosion.BlastRadius = radius
explosion.Position = position
local hitConnection
hitConnection = explosion.Hit:Connect(function(part, distance)
if partsHit[part] then
return
end
if collectionService:HasTag(part, "Destructible") and not collectionService:HasTag(part, "HitPart") then
partsHit[part] = true
local total = playerScores:FindFirstChild(playerName)
if not total then
local value = Instance.new("IntValue")
value.Name = playerName
value.Value = 1
value.Parent = playerScores
else
total.Value = total.Value + 1
end
for i,v in pairs(part:GetTouchingParts()) do
if collectionService:HasTag(v, "Destructible") then
v:BreakJoints()
end
end
delay(5, function()
part:Destroy()
end)
collectionService:AddTag(part, "HitPart")
end
end)
explosion.Parent = workspace
delay(0.25, function()
hitConnection:Disconnect()
end)
end
return module