I’m working on an airstrike, using the roblox airstrike tool as a base because I have no idea how to program something like that, but I wanted to add custom explosions. I got the explosions working by just cloning a particleemitter from serverstorage and parenting it to the bomb model but there is one problem, when the bombs drop they explode mid air instead of on the ground now, and I have no idea why, do particles have a hitbox or something?
local bomb = script.Parent
bomb.Touched:Connect(function(hit)
if hit:IsA("Part") then -- Just configure the code if you don't want this. I personally keep it as a "Part" most of the time or remove if you don't want it.
-- Insert explode code.
-- Add particles etc.
elseif hit:FindFirstChild("Humanoid") then
local player = hit.Parent -- Insert explode code beneath this line.
player:WaitForChild("Humanoid"):TakeDamage(40) -- Change this to whatever health it should take away.
else
return
end)
-- This would prevent the bomb from going off before it touches a part. If you have a certain time limit where the bomb is exposed, you might want to consider lowering the height from where they drop.
Its already being done, it creates a local function and fires it when it touches and makes sure it isnt the effect or the bombing jet itself.
Here is the portion of the script that handles it (I do not take credit for making this airstrike btw all credit goes to StarWars)
local function Explode(bomb)
if not bomb.Exploded then
bomb.Exploded = true
bomb.Model.Anchored = true
bomb.Model.Transparency = 1
local Sound = bomb.Model:FindFirstChild("Sound")
if Sound then
Sound:Play()
end
game.ReplicatedStorage.Boom:FireAllClients()
local Explosion = Instance.new("Explosion")
local Particles = game.ServerStorage.ExplosionParticles:Clone()
Particles.Parent = bomb.Model
Explosion.Position = bomb.Model.Position
Explosion.BlastPressure = BLAST_PRESSURE
Explosion.BlastRadius = BLAST_RADIUS
Explosion.ExplosionType = Enum.ExplosionType.CratersAndDebris
Explosion.Visible = false
Explosion.Hit:connect(function(hit)
if bomb.Creator and (hit.Name == "Head" or hit.Name == "HumanoidRootPart") then
local Humanoid = hit.Parent:FindFirstChild("Humanoid")
if Humanoid then
for _, v in ipairs(Humanoid:GetChildren()) do
if v.Name == "creator" then
v:Destroy()
end
end
local NewCreator = CreatorValue:Clone()
NewCreator.Value = bomb.Creator
NewCreator.Parent = Humanoid
end
end
end)
Explosion.Parent = workspace
wait(1)
if bomb.Model and bomb.Model.Parent ~= nil then
bomb.Model:Destroy()
end
end
end
function Bomb.new(jet)
local self = {}
setmetatable(self, Bomb)
self.Model = CreateBomb(jet)
self.Creator = jet.Creator
self.Exploded = false
self.Model.Touched:connect(function(hit)
if hit and hit.Parent then
if hit.Name ~= "Effect" and hit.Parent.Name ~= "F22 Bombing Jet" then
Explode(self)
end
end
end)
return self
end
return Bomb