Trying to compare items in a table, can't seem to get it right. Any help?
Asked by
5 years ago Edited 5 years ago
I've been working on my own GUI Module so that I can edit GUI a bit faster in-game.
I've made this function inside a module script to change the color of the player's interface.
Here it is:
02 | function GuiModule.ChangeColor(guiTable, ignoreTable, guiColor) |
03 | local defaultColor = Color 3. fromRGB( 255 , 255 , 255 ) |
04 | for i, v in pairs (guiTable) do |
05 | if v:IsA( "GuiObject" ) then |
06 | if v ~ = ignoreTable [ i ] then |
07 | v.BackgroundColor 3 = guiColor or defaultColor |
08 | v.BorderColor 3 = guiColor or defaultColor |
09 | if v:IsA( "ImageButton" ) or v:IsA( "ImageLabel" ) then |
10 | v.ImageColor 3 = guiColor or defaultColor |
19 | local colorButtons = colorButtons:GetChildren() |
20 | local interfaceTable = screenGui:GetDescendants() |
24 | for _, button in pairs (colorButtons:GetChildren()) do |
25 | if button:IsA( "ImageButton" ) then |
26 | button.MouseButton 1 Down:Connect( function () |
27 | GuiModule.ChangeColor(interfaceTable, colorButtons, button.ImageColor 3 ) |
The basic idea is to have a table of GUI I do want to change, a table that I dont want to ignore, and a color to change them to.
However, when I compare the iteration and value to the ignore table, it still changes the colors of the ones I dont want to change. Its like 5am and Im not too sure what im doing wrong, or if im just really tired. Heres a gif of whats going on; and a gif of whats supposed to happen.
Whats happening:
https://gyazo.com/a91067c7fcd42f974d034806bccbb187
Whats supposed to happen (I removed the :IsA("ImageButton") check:
https://gyazo.com/dd3dbd06ac26c7a7fc7d522653d2c3c4
The reason I have the image button check in the first place, is because this is modularized, its going to be able to work in pretty much every situation. The only items I want to ignore are the ones in the ignore table, the only items I want to change are the ones in the guiTable, you get the idea.
Thanks for any help.