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 make a system to mass unanchor parts?

I'm trying to make a tool that when clicked, it will summon a part that then checks if any parts it touches is unanchorable, and if so, it will unanchor it. I'm trying to do this in large quantities, so I can't use a ClickDetector or put a script into every part. I can, however, put a script into the tool, the part that unanchors touched parts, or the folder of parts. I've tried a script in the part that basically unanchors anything detected with the part.Touched event, and it didn't work. This is the script that is currently in the folder:

wait()

while true do
	local destrutableObjects = script.Parent:GetChildren()
	wait()
	for i,obj in pairs(destrutableObjects) do
		if obj:IsA("BasePart") then
			obj.Touched:Connect(function(hit)
				if hit.Name == "Explosion" then
					obj.Anchored = false
				end
			end)
		end
	end
end

There are no errors. I've tried debugging with print() functions, and it seems that it never activates the function, but gets into the for loop. I have no idea why. Again, I cannot put an Instance into every part for performance on low-medium devices.

1 comment

0

comment for 116'000th question!

1 answer

maybe try using "Hit" instead of "obj"?

4 comments

0

I have two variables. One is named obj, and the other is named hit. obj is the part that should be destructible, it is taken from a for loop going through a folder of parts. Hit is supposed to be the explosion that touches the part. What the script tries to do is add a function for each part, while not adding a script to every part.

0

try using "Hit.Parent"

0

That shouldn't affect anything, because the code never even gets into the function where I make hit a variable.

0

Found the answer. In the actual projectile, :BreakJoints() on the parts that get hit.

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