Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

[Solved] How do I make an explosion destroy parts instead of send them flying?

Asked by 8 years ago
Edited 8 years ago

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!

0
I'm not sure :connect() can have a capital C. Try changing that, maybe? nicemike40 486 — 8y
0
Yes you can use 'Connect' as 'connect is now depricated, http://wiki.roblox.com/index.php?title=RBXScriptSignal#Methods User#5423 17 — 8y
0
I think there is a extra end at line 19. SH_Helper 61 — 8y
0
Just tried deleting the end at line 19, all it did was break the script and give me an error :/ WesleyTheSkunk 12 — 8y
View all comments (2 more)
0
You'd have to make an invisible part or use region3 to get parts in that area then delete them alphawolvess 1784 — 8y
0
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 WesleyTheSkunk 12 — 8y

Answer this question