How can I change the transparency of 6 different image labels all at the same time?
Currently I have them all defined like this:
local classBorders = {script.Parent.Parent.BDs.classBDx, script.Parent.Parent.BDs.classBDx1, script.Parent.Parent.BDs.classBDy, script.Parent.Parent.BDs.classBDy1, script.Parent.Parent.BDs.classBDz, script.Parent.Parent.BDs.classBDz1}
However when I try change the transparency it won't work.
We can use something called for loops
for this. for loops lets you run a command or group of commands at a set number of times, or we can use it to iterate through tables/arrays. It should look something like this:
local Alphabet = {"A", "B", "C", "D"} -- Your table here for i,v in pairs(Alphabet) do -- You can name i and v anything you want. i stands for index and v stands for value print(i .. " | " .. v) task.wait(1) -- Just some extra stuff, and task.wait is exclusive to Roblox, Lua doesn't officially have this syntax. print(v .. " is in the alphabet!") end
Output:
1 | A
2 | B
3 | C
4 | D
Script waits for 1 second
A is in the alphabet!
B is in the alphabet!
C is in the alphabet!
D is in the alphabet!
And you can play around with this, like changing all of the parent's children's property. (e.g changing every x's children transparency to 0.5)
This, of course isn't a complete tutorial about for loops. You can see more in the DevForum link @Ziffixture sent in the comment section.
Happy scripting!