Rising Lava Collapsing Buildings?

I am working on a simple concept for a game where its the classic floor is lava, or the lava rises and you must go higher up to avoid it.

How can I achieve a system in which the rising lava will make the building(s) in the maps collapse?
I have thought about having them be unanchored and welded, but how would I be able to make it so that the lava can cause the weld or something to be broken off, making the pieces of the building collapse or fall or break.

Thank you in advance to anyone who can help!

1 Like

make the lava a hitbox and detects when a building part is touched and destroy the welding

1 Like

Paste this into the rising lava part:

script.Parent.Touched:Connect(function(hit)
if hit and hit.Parent and hit:IsA('Part') and not (hit.Parent:FindFirstChild('Humanoid')) then --you may need to add other checks to confirm the object that gets hit is part of a building.
hit.Anchored = false
if hit:FindFirstChild('Weld') then
hit:FindFirstChild('Weld'):Destroy()
end
end)

Let me know if you have questions.

1 Like

fixed to destroy all descendant welds

script.Parent.Touched:Connect(function(hit)
  if hit and hit.Parent and hit:IsA('Part') and not (hit.Parent:FindFirstChild('Humanoid')) then --you may need to add other checks to confirm the object that gets hit is part of a building.
    hit.Anchored = false

    for _, weld in ipairs(hit:GetDescendants()) do
      if weld:IsA("Weld") == false then continue end
      weld:Destroy()
    end

  end
end)
1 Like

This did the trick, just changed a couple things and ran some tests and it worked, thank you everyone for the help!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.