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

How to expload terrain when a part touches it?

Asked by 3 years ago

So I am trying to make a deadly Leaser Beam that destroys everything in its way though I am having a issue with terrain because when you try to set its parent it errors. My issue is that when the Laser Beam hits the terrain a explosion never spawns, and I am sure of that as I tested that when the Laser Beam hits the Terrain it never prints anything if I add a print. Also occasionally for some reason it says it cannot change Terrain's parent even though I have a filter so it will never change Terrain's parent, my Theory behind that is its just too much lag. Here is my script:

script.Parent.Activated:Connect(function()
    if script.Parent.Parent.Name ~= "Gooncreeper" then
                script.Parent:Destroy()
    elseif script.Parent.Parent.Parent.Name ~= "Gooncreeper" and script.Parent.Parent.Name == "Backpack" then
        script.Parent:Destroy()
    end
    ToolLocation = script.Parent
    script.Parent = game.Lighting
    ToolLocation:Destroy()
    game.Lighting.DEATHBEAM.Parent = game.Workspace
    Message = Instance.new("Message", game.Workspace)
    for i = 1, 10 do
        Message.Text = "World Destruction In: ".. 10 - i
        wait(1.5)
    end
    PartLength = 0
    Message:Destroy()
    repeat
        game.Workspace.DEATHBEAM.BEAM.Size = game.Workspace.DEATHBEAM.BEAM.Size + Vector3.new(5,0,0)
        PartLength = PartLength + 5
        game.Workspace.DEATHBEAM.BEAM.Position = game.Workspace.DEATHBEAM.BEAM.Position + Vector3.new(-2.5,-2.25,0)
        wait(0.01)
        PartsTouchingBeam = game.Workspace.DEATHBEAM.BEAM:GetTouchingParts()
        for i, v in pairs(PartsTouchingBeam) do
            if PartsTouchingBeam[i] ~= game.Workspace.DEATHBEAM.Part then
                if PartsTouchingBeam[i].Name ~= workspace.Terrain then
                    PartsTouchingBeam[i]:Destroy()
                else
                    ExplodeTerrain = Instance.new("Explosion")
                    ExplodeTerrain.Position = PartsTouchingBeam[i].Position
                    ExplodeTerrain.Visible = false
                    ExplodeTerrain.Parent = game.Workspace
                    ExplodeTerrain:Destroy()
                end
            end
        end
    until PartLength == 10000
end)
0
Terrain can't explode. It's that simple. Nothing you do will ever change that as of now. You can only make it look like the terrain exploded. SteamG00B 1633 — 3y

2 answers

Log in to vote
0
Answered by
Raccoonyz 1092 Donator Moderation Voter
3 years ago

What you are checking for is if the name of the part is equal to an object. Comparing a string with an object will always return false. This means that it will always try to destroy the terrain. A fixed version would be this:

if PartsTouchingBeam[i].Name ~= "Terrain" then

0
I changed that, it did not error but it was producing alot of lag still, I think that is due to the ammount of checks its doing in a short peroid of time, Also the terrain did not expload so this is not answering my question entirely, So how would I make the terrain expload? Gooncreeper 98 — 3y
Ad
Log in to vote
0
Answered by 3 years ago

You cant explode terrain, due to how roblox made it.

The only way you can do it is if you create terrain using blocks and parts, which can be very tricky if you have lots of mountains and holes.

sorry to be the bringer of bad news.

0
You can explode terrain. Explosions with a large enough BlastRadius and BlastPressure will destroy smooth terrain. Rinpix 639 — 3y
0
I've tried and it doesnt work any more IncredibleTeamAidan 104 — 3y

Answer this question