I am creating a demolition game which ideally should rely on explosions as the primary method for causing mayhem.
Originally, all was working as intended and so I had left the script without touching it for quite a while. At some point of developing the game, the explosions stopped registering the parts it had previously recognised.
While I can go through the saves and try to compare everything until I find the solution, I was hoping someone would be able to offer ideas as to what has happened.
The desired parts, which are the destructible parts are not registered. Right now I am using explosion.Hit as I want, but no luck. I have also tried to use :GetPartBoundsInRadius but that offered the same results.
As a test, I put some other unchanged parts in the field of the explosions, and they seem to be affected as I intended and as the destructible parts originally were.
What reasons could cause a part to not be passed to either of these methods?
What i tried:
- Not setting collision groups
- Brute forcing the GetPartBoundsInRadius
- Creating a sphere with the radius and getting all parts within the sphere
- Yes all the Can properties of the destructible baseparts are true
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
My dodgy explosion module
local Explosions = {}
-- Add explosion sound
function Explosions.new(position, force, radius, damage)
local EntityDebounce = {}
local explosion = Instance.new("Explosion")
explosion.BlastRadius = radius
explosion.Position = position
explosion.BlastPressure = force
explosion.DestroyJointRadiusPercent = 0
explosion.Parent = workspace.Game.CleanUp
local params = OverlapParams.new()
params.BruteForceAllSlow = true
local parts = workspace:GetPartBoundsInRadius(explosion.Position, radius, params)
print(parts)
explosion.Hit:Connect(function(part)
if not part.Parent:FindFirstChildOfClass("Humanoid") then
if part.CollisionGroup == "Island" then
part.Anchored = false
task.wait()
part:ApplyImpulse((part.Position - explosion.Position).Unit * force * part:GetMass())
end
else
local humanoid = part.Parent:FindFirstChildOfClass("Humanoid") or part.Parent:FindFirstChildOfClass("HumanoidController")
if not table.find(EntityDebounce, humanoid) then
humanoid:TakeDamage(damage)
table.insert(EntityDebounce, humanoid)
end
end
end)
end
return Explosions
The script where an explosion is requested
--Variables
local Part = script.Parent.Sphere;
local Force = -2000;
local Debris = game:GetService("Debris")
local sss = game:GetService("ServerScriptService")
local Explosions = require(sss.Assets.Explosions)
local sound = script.Parent["collide.wav"]
Part:SetNetworkOwner(nil)
Part.Touched:Once(function(part)
local part = Instance.new("Part")
part.Size = Vector3.new(.1,.1,.1)
part.CanCollide = false
part.CollisionGroup = "Intangible"
part.Anchored = true
part.Position = Part.Position
sound.Parent = part
part.Parent = workspace.Game.CleanUp
sound:Play()
Debris:AddItem(part, 1)
Explosions.new(part.Position, 30, 8, 200)
Debris:AddItem(script.Parent, 0)
end)
Part:ApplyImpulse(Vector3.yAxis * Force)
func = function(event) -- Metor Shower
local metor = event_assets.Metor
local duration = math.random(10, 30)
local metors = math.random(10, 30)
local time_between = duration/metors
for i = 1, metors, 1 do
local start = ReturnRandomMapXYPosition() + Vector3.new(0,100,0)
local clone = metor:Clone()
clone.PrimaryPart.Position = start
clone.Parent = workspace.Game.CleanUp
task.wait(time_between)
end
end}
Please let me know if you need anything more and thank youuu