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

How do I change multiple blocks (named the same thing) at once?

I want to change 24 blocks 'Anchored' property, but I really don't want to have to change all 24 of their names, and then put them all into the script. Is there a way to make all 24 blocks named PlatformA to be unanchored without writing 48 different lines of code?

2 answers

✓ Accepted answer

Yes, there is a way, and I'll explain. Here's the code for it, I'll explain in comments.

a = game.Workspace:GetChildren() --If the platforms are in a model, change this as necessary

for i,v in pairs(a) do --Sorts through a's children
	if v.Name == "PlatformA" then --Selects all of a's children that are named PlatformA
	v.Anchored = false
	end
end

I hope this made some sense to you. Thanks!

Group them and then un group them once you finish teh script, use i,v in pairs() method and v: IsA(part) method

2 comments

0

BTW, Not a request site

0

And use GetChildren too

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