Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 10 years ago

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

Log in to vote
2
Answered by 10 years ago

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!

Ad
Log in to vote
-1
Answered by 10 years ago

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

0
BTW, Not a request site PlatinumLocks 50 — 10y
0
And use GetChildren too PlatinumLocks 50 — 10y

Answer this question