im making a script that changes the border color of my gui,but i dont want to make a spam of ipairs because my gui have alot of frames and textbuttons
this is the script i used that works fine (only affects one frame)
Console = script.Parent.Parent.Console function Red() for _, child in ipairs(Console:GetChildren())do if child:IsA("TextButton") then child.BorderColor3 = Color3.new(255,0,0) end end end
i tried this but it dint work
Console = script.Parent.Parent.Console Music = script.Parent.Parent.Music Gears = script.Parent.Parent.Gears stuff = {Console,Music,Gears} function Red() for _, child in ipairs(stuff:GetChildren())do if child:IsA("TextButton") then child.BorderColor3 = Color3.new(255,0,0) end end end
Loop through your stuff table and iterate through that.
-Also changed your Color3 to Color3.fromRGB, because color3.new() uses percentages from 0 to 1.
local Console = script.Parent.Parent.Console local Music = script.Parent.Parent.Music local Gears = script.Parent.Parent.Gears local stuff = { Console, Music, Gears } function Red() for _,ThingFromStuff in ipairs(stuff) do for _, child in ipairs(ThingFromStuff:GetChildren())do if child:IsA("TextButton") then child.BorderColor3 = Color3.fromRGB(255,0,0) end end end end