Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How would I get a model's parts to unanchor individually?

I'm currently scripting a game where it involves a map's parts unanchoring indivually. Am I doing anything wrong here?

local unanchoredPart = workspace.MapTemplate.Part

function onTouch(part)
	unanchoredPart.Anchored = false
end

unanchoredPart.Touched:connect(onTouch)

This is the full script.

1 comment

0

normal script

1 answer

Use a generic for loop to get all the parts in the model. Then see if the person touches it.


#Final Code Make sure you see if there is a humanoid in the part's parent. This way the parts don't fall by touching the rest of the map.

for _,p in pairs(workspace.MapTemplate:GetChildren()) do
	p.Touched:connect(function(part)
		if part.Parent:FindFirstChild("Humanoid") then
			p.Anchored = false
		end
	end
end


Hope it helps!

1 comment

0

Would this happen to work in a LocalScript or a normal script?

This discussion is preserved as it was. New answers, comments, and votes are closed.