Hey i need help with a monster

I wanna make it so when the monster goes through blocks it makes them unanchored so like if it walks through a house, it would get destroyed.

Maybe something like this in a server script under the zombie model.

local collectionService = game:GetService("CollectionService")
local zombie = script.Parent

for i, part in ipairs(zombie:GetChildren()) do
	if part:IsA("BasePart") then
		part.Touched:Connect(function(h)
			if collectionService:HasTag(h, "Breakable") then
				h.Anchored = false
			end
		end) 
	end
end
2 Likes

I see you liked the code, but you didn’t mark a solution, did it not work, and how can I fix it?

You don’t need to check this. UnionOperation and Part are all BaseParts.

1 Like

Yes, you are correct, I should have checked that.

It didnt work and sorry it wasnt letting me send my message

Did you give all the breakable blocks the tag Breakable, and put the script as a child under the zombie model?

yeah i did all of that, maybe its that loop part.

If the script has no siblings, it will not work.

uh what do u mean by
siblings?

Does the script.Parent have other children, which would be siblings.

Yeah its a dummy model, the script is under the model and every part in the map is anchored so idk.

Did the dummy Model the script is under, touch a block with the Breakable tag?

wait is it suppose to be under one of the dummy parts? and like idk why i am just asking this but wdym breakable tag?

The script should be placed under the model, not under a part, also the Breakable tag is used to identify the parts to be “Breakable”, look at CollectionService and the Tag Editor Plugin.

Ok i just did, when i put the tag on a folder does it still work on the parts because if not, thats gonna be alot of stuff to do.

I am confused about what you are asking, can you please explain?

i searched up collection thing and the plugin.I used the plugin and i was asking if it would work on folders

The code I provided checks if the specific part has the tag, but we can modify it to include if it is a child of a folder with the tag, but I wouldn’t recommend that.

So then what would u recommend then?