Group of parts get unanchored on touch

the script below makes a part unanchored when touched, though can someone help or make it so it unanchored a group? im unsure how to explain but i want to make buildings collaps and so i want it to unanchor all parts of the building at once when only one is touched. (i will weld the ones i want to stick together)

function OnTouch(part)
	h = part.Parent:findFirstChild("Humanoid")
	if h ~= nil then 
		script.Parent.Anchored = false 
	end 
end 

script.Parent.Touched:connect(OnTouch)
2 Likes

this should make all of a models (assuming its all in 1 model) parts unanchored.

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

script.Parent.Touched:Connect(OnTouch)
5 Likes

should the different part be anchored or unanchored in the beginning? (anchored it didnt work) edit: stupid me forgot to implement the script, testing now, edit2: it worked, thanks!