Making parts fall together when base is gone [Solved]

I’ll keep it simple and short. Just need an idea or method, don’t need the code, I’ll make that part. But when you place the block it anchors it, nothing else. When the bottom blocks get destroyed I need the remaining top blocks to fall down, I’ll just unanchor them. But when they fall down they need to fall down together, all connected. (Perhaps welds?)

Before:
image

After:

What approach would you do?

Can you show what it looks like when you just delete the bottom part normally?

yeah so all the parts have welds connected to each other. But I’m trying to figure out how to approach when lets say a leg or not a single part is touching the ground how to detect that. This way the entire structure falls down:

1 Like

Weld the top to the bottom.
And only anchor the bottom one?

Can you describe the system or the game where this will be used so we can better understand how to help you?

is this what you are trying to do?
I’ve found that you can’t have unanchored parts and expect them to not move after being welded so I created a small script.

the structure is not organized and I had to manually weld them and destroy the Base part but you got the main point.

code
local model = script.Parent
local base = model.Base
local children = model:GetChildren()

base.Destroying:Connect(function()
	for _,part: Part in children do
		if part:IsA("Part") and not (part.Name == "Base") then
			
			part.Anchored = false
			
		end
	end	
end)
1 Like

thank you for the response! Yeah so pretty much imagine you have a platform and there are multiple legs. Lets say all the legs get removed, than the platform, while all connected to each other will fall down. But lets say only one leg is removed, than it still stands.

Hey so I just figured a different way of doing. I’d have the parts crate a region 3x3x3 around it. If there’s a block in it, check that region 3x3x3 and so on. Making sure to ignore previous blocks too. I don’t know how to close posts. But for those interested in the code here it is:

-- Assuming the script is inside the block with Health as an attribute
local block = script.Parent
local health = block:WaitForChild("Health") -- Assume Health is an attribute on the block

-- Function to create a new 3x3x3 block
local function createBlock(position, woodBlock)
	-- Create a new 3x3x3 block
	local newBlock = Instance.new("Part")
	newBlock.Size = Vector3.new(3, 3, 3)
	newBlock.Position = position
	newBlock.Anchored = true
	newBlock.Transparency = 0.5
	newBlock.Parent = workspace

	-- Check if the woodBlock already has the "Processed" tag
	if woodBlock:FindFirstChild("Processed") then
		return  -- If it already has a Processed tag, don't create a new block
	end

	-- Mark the woodBlock as processed by adding a "Processed" attribute or BoolValue
	local processedTag = Instance.new("BoolValue")
	processedTag.Name = "Processed"
	processedTag.Value = true
	processedTag.Parent = woodBlock

	-- Check for blocks within the 3x3x3 area
	local region = Region3.new(position - Vector3.new(1.5, 1.5, 1.5), position + Vector3.new(1.5, 1.5, 1.5))
	local partsInRegion = workspace:FindPartsInRegion3(region, nil, math.huge)  -- Get all parts in the region

	for _, part in ipairs(partsInRegion) do
		-- Ignore the newBlock itself
		if part ~= newBlock then
			-- If the part has "Health" and has not been processed already
			if part:FindFirstChild("Health") and not part:FindFirstChild("Processed") then
				local woodRegion = Region3.new(part.Position - Vector3.new(1.5, 1.5, 1.5), part.Position + Vector3.new(1.5, 1.5, 1.5))
				local partsNearWood = workspace:FindPartsInRegion3(woodRegion, nil, math.huge)
				for _, nearPart in ipairs(partsNearWood) do
					if nearPart.Name == "Wood" then
						-- Call createBlock again for this part if it has "Wood"
						createBlock(part.Position, part)  -- Pass the wood block to mark it processed
						break  -- Stop searching once we find "Wood"
					end
				end
			end
		end
	end
end

-- Function to handle Health changes
local function onHealthChanged()
	if health.Value == 0 then
		-- Create a new 3x3x3 block centered at the current block's position
		createBlock(block.Position, block)
	end
end

-- Connect the function to the Health attribute value change
health:GetPropertyChangedSignal("Value"):Connect(onHealthChanged)

1 Like