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)
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
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.