Make group of parts unanchor on touch

Here is what I came up with:
You can’t unanchor a model, you have to go an unanchor all the parts of it. I had problems with the welds, so the individual pieces are just dropping (a little more realistic too).

local db = false

function OnTouch(part)
	local h = part.Parent:FindFirstChild("Humanoid")
	if h and not db then
		for i,v in pairs(script.Parent.Parent:GetChildren()) do
			v.Anchored = false
		end
	else
		return
	end
end

script.Parent.Touched:Connect(OnTouch)

–edit: explained it

1 Like