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

Can for loops be used to change properties?

Asked by 6 years ago

I haven't fully understand For Loops, but i've tried some very simple and basic practice Now i'm trying to do some more things that's more advanced However, i can't seem to change a part properties, or i don't know if that is possible using for loops. I can however, use a while loops to change properties.

1 answer

Log in to vote
1
Answered by
Amiaa16 3227 Moderation Voter Community Moderator
6 years ago
Edited 6 years ago

Yes you can use for loops to change properties.

Let's say you want to change color of all parts in workspace to red

for i,v in pairs(workspace:GetChildren()) do
    if v.ClassName == "Part" then --if it's a part
        v.BrickColor = BrickColor.Red()
    end
end

i is a number which increments each time, while v is the part

You can obviously name them anything you want, such as i,part

0
you can just say if v:IsA"BasePart" to get any part User#19524 175 — 6y
0
I know. I simply tried to explain it in a noob friendly way Amiaa16 3227 — 6y
Ad

Answer this question