Is there a way to make building unanchored when you deal a certain amount of damage to them

I want the building to fall when a player does a certain amount of damage to the building
and after a certain amount of time say 12 minutes the building fixes back to its normal stage now if there is a solution with the least lag I would be glad to hear it but laggy solutions will find as well.

2 Likes

what do u mean by damage buildings?

Do you have a damage system created?

I attempted but the system resulted in nothing

I started with something simple like a giant humanoid covering my building and setting up functions on the humanoid and if it dies the building falls but that doesn’t work.
Other than that this is my first time attempting something like this.

1 Like

Three ways:

If you want the Player to shoot the building without it being damaged until they’ve done the limit (say 20 shots and the building falls) then make a counting system that adds 1 to it every time the player damages it. When the counter reaches 20 then have a script that adds all the Parts into a table and makes Part.Anchored = false when that happens.

Use a script so that the explosions make Parts that are hit Part.Anchored = false. This would mean having sections hanging in the air if the player causes explosions just around the bottom of the walls.

You could weld all the smaller Parts (Unanchored) to the Parts below them and have the damage make the welds inactive for the Part that’s hit as well as the ones above it.
If you weld all the Parts to a common Anchored Part then when a player shoots just the bottom of the building walls the Parts above it might hang in the air unsupported.

2 Likes

You can use Model:BreakJoints() for this too

2 Likes

here’s a small script I made of a basic system that regens the block in its original position after 12 minutes

local building = game.Workspace.Building
local cd = building.ClickDetector
local backUp = building:Clone()
local damage = 0
local RefreshTimer = 12 --Minutes

backUp.Parent = game.ReplicatedStorage

function Refresh()
	building:Destroy()
	building = backUp:Clone()
	building.Parent = game.Workspace
end

cd.MouseClick:connect(function()
	if building.Anchored == false then return end
	
	damage += 1
	if damage == 10 then
		damage = 0
		building.Anchored = false
	end
end)

while task.wait(RefreshTimer*60)do
	Refresh()
end

Basically what is happening is the script defines the building and clones it into replicated storage and defines that one as the back up. Then after its clicked 10 times it is unanchored. After 12 minutes the building variable is defined as the same as the back up and parented back to workspace (this shouldn’t lag unless there is alot of parts being un anchored which you can not really fix)

2 Likes

here is another script I made that requires the player to have a hammer with a handle inside.

local building = game.Workspace.Building

local backUp = building:Clone()
local damage = 0
local RefreshTimer = 12 --Minutes

backUp.Parent = game.ReplicatedStorage

function Refresh()
	building:Destroy()
	building = backUp:Clone()
	building.Parent = game.Workspace
end

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:connect(function(char)
		local hammer = plr.Backpack.Hammer
	
		hammer.Equipped:connect(function()
			local handle = char.Hammer.Handle
			
			handle.Touched:connect(function(hit)
				print("hit" ..hit.Parent.Name)
				if hit.Parent == building and building:FindFirstChildOfClass("Part").Anchored == true then
					damage += 1
					print(damage)
					if damage == 10 then
						damage = 0
						for i,v in pairs (building:GetChildren())do
							if v:IsA("Part")then
								for i,v in pairs(v:GetChildren())do --Checks for welds holding them together
									if v:IsA("Weld") then
										v:Destroy()
									end
								end
								v.Anchored = false
							end
							
						end
						print("Building Destroyed")
					end
				end
			end)
		end)
	end)
end)




while task.wait(RefreshTimer*60)do
	Refresh()
end

This basically just checks if the handle is touching anything (could also be a bullet) and ounce you hit the building 10 times it will loop through and unanchor the parts while also removing welds holding them together. Hope this helps :slight_smile:

1 Like

The damage variable eat the top is that the health?

It says IsAwield this building has no wields and is anchored can I pass building:BreakJoints()

BreakJoints doesn’t work for Anchored Parts.

I tried Model.anchored = false that doesn’t work

But Anchored isn’t a Property of Model. It’s a Part Property.
Read my post above with the 3 recommendations, including:
“When the counter reaches 20 then have a script that adds all the Parts into a table and makes Part.Anchored = false when that happens.”

You should loop through the model and unanchor them like shown in the script I did

yes, that is the health, how much hits it has until it breaks.