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

Can for loops be used to change properties?

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

✓ Accepted answer

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

2 comments

0

you can just say if v:IsA"BasePart" to get any part

0

I know. I simply tried to explain it in a noob friendly way

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