So I'm a beginner to roblox lua scripting (and just scripting in general), and right now I'm working on the first game I've scripted myself. I've been making a bomb survival game, but I need help with the bombs exploding. They explode just fine, but I would like to make it so when they explode, instead of sending the parts of the ground around them flying, they would just destroy them. However, I would also like to make it so they can only destroy the ground, not the entire baseplate or any of the invisible borders I set up around my arena to prevent players and bombs from falling off the map. What I'm doing is using the hit function of an explosion to check if the part is anchored and destroy it if it isn't, but clearly I'm doing that wrong. Here is the part of my bomb's script that creates the explosion:
local function explode() local explosionEffect = shockWave:Clone() explosionEffect.Parent = game.Workspace explosionEffect.Position = bomb.Position local explosionEffect2 = shockWave2:Clone() explosionEffect2.Parent = game.Workspace explosionEffect2.Position = bomb.Position local explosion = Instance.new("Explosion", game.Workspace) explosion.Position = bomb.Position explosion.BlastRadius = explosionRadius explosion.BlastPressure = 400000 explosion.Visible = false explosion.Hit:Connect(function(hitPart) if hitPart.Anchored == false then hitPart:Destroy() end end) end
Ignore the first block of code, that's just there to create my custom explosion effect. The second block, the one that creates the actual explosion, is what I need help with. Thanks!