Is there a way to create custom explosions (using base parts) that can act like regular explosions that don’t use the explosion instance? And if so, how can I do this?
example below

the explosion should be capable to :
•Kill players
•Push parts away like a regular explosion would
•Destroy joints, welds etc
Yep just use spatial query :GetPartsIn sphere, detect humanoids using part.Parent and findfthe humanoid, you can then use :ApplyImpulse() and :GetJoints() and destroy them (:BreakJoints is deprecated and only works while model is in workspace btw).
Thanks but how do I get the direction that the impulse should be applied? One of the arguments for :ApplyImpulse is a vector3
No worries,
You can get the direction using target part position - explosionOriginPosition.
A classic formula:
1 Like
Thanks but I couldn’t find the get parts in sphere function on the documentation, are you sure it does exist as a function?
If not then would I do something like
GetPartsInPart(explosion) and then check if the parts are from a certain magnitude to one another?
Whoops, sorry its actually get parts bound in radius.
1 Like
Another thing (sorry for constant replies), how could I calculate the actual power of the force that applies to the parts?
No worries, you can scale it numerically same way as damage. There is sample code on the explosion instance its a linear equation.
local function customExplosion(position, radius, maxDamage)
local explosion = Instance.new("Explosion")
explosion.BlastPressure = 0 -- this could be set higher to still apply velocity to parts
explosion.DestroyJointRadiusPercent = 0 -- joints are safe
explosion.BlastRadius = radius
explosion.Position = position
-- set up a table to track the models hit
local modelsHit = {}
-- listen for contact
explosion.Hit:Connect(function(part, distance)
local parentModel = part.Parent
if parentModel then
-- check to see if this model has already been hit
if modelsHit[parentModel] then
return
end
-- log this model as hit
modelsHit[parentModel] = true
-- look for a humanoid
local humanoid = parentModel:FindFirstChild("Humanoid")
if humanoid then
local distanceFactor = distance / explosion.BlastRadius -- get the distance as a value between 0 and 1
distanceFactor = 1 - distanceFactor -- flip the amount, so that lower == closer == more damage
humanoid:TakeDamage(maxDamage * distanceFactor) -- TakeDamage to respect ForceFields
end
end
end)
explosion.Parent = game.Workspace
-- Roblox removes explosions after a few seconds, but does not destroy them.
-- To ensure our .Hit connection gets disconnected, destroy the explosion once it's removed.
explosion.AncestryChanged:Connect(function()
if not explosion.Parent then
explosion:Destroy()
end
end)
end
customExplosion(Vector3.new(0, 10, 0), 12, 50)
2 Likes
Wait is the .Hit event even a real event? I couldn’t find its documentation