Unlocked character buttons

Hi, so I’m not that crazy at scripting and I need some help. So in my game there are multiple unockable characters and I have a gui full of buttons to select them. I want the buttons to appear darker for characters that are not unlocked. There is a folder under the LocalPlayer full of BoolValues, one for each character. I want to make it so that if the boolvalue is true, the respective button in the GUI will have the ImageTransparency set to 0, and if the value is false, (meaning the character is not unlocked), have the transparency at 0.5.

The values and buttons have the same name so I assume a simple table could be used but idk how to do that. Basically I just want “If this value is true, the button of the same name is visible.”

This should be similar to what you want to achieve.

for _, bools in pairs(boolFolder:GetChildren()) do
   if bools.Value then
      buttonsFrame:FindFirstChild(bools.Name).ImageTransparency = 0
   else
      buttonsFrame:FindFirstChild(bools.Name).ImageTransparency = 0.5
   end
end

If you really want to shorten it, you could just do

for _, bools in pairs(boolFolder:GetChildren()) do
   buttonsFrame:FindFirstChild(bools.Name).ImageTransparency = bools.Value and 0 or 0.5
end

Blockquote

preciate that lol very simple

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.