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!

6 comments
I'm not sure :connect() can have a capital C. Try changing that, maybe?
Yes you can use 'Connect' as 'connect is now depricated, http://wiki.roblox.com/index.php?title=RBXScriptSignal#Methods
I think there is a extra end at line 19.
Just tried deleting the end at line 19, all it did was break the script and give me an error :/
You'd have to make an invisible part or use region3 to get parts in that area then delete them
Ok I know this question is really old but I just figured it out, I needed a wait() between the bomb exploding and the bomb being destroyed