I'm trying to make a gui that provides admin commands, but I don't want to copy the code to make the buttons, so I decided to use a for loop. However, if a button is pressed, the script will not know which button was pressed. So could someone please show me how to make the buttons work independently while still using a for loop?
Options = {
"Fly",
"ForceField",
}
for _, v in pairs(Options) do
local TextButton = Instance.new("TextButton", ScreenGUI)
TextButton.Text = v
TextButton.BackgroundColor3 = Color3.fromRGB(56, 56, 56)
TextButton.Font = Enum.Font.SourceSansItalic
TextButton.TextSize = 20
TextButton.TextColor3 = Color3.fromRGB(255, 255, 255)
local UICorner = Instance.new("UICorner", TextButton)
UICorner.CornerRadius = UDim.new(0, 5)
local UIGradient = Instance.new("UIGradient", TextButton)
UIGradient.Rotation = 90
UIGradient.Color = ColorSequence.new({
ColorSequenceKeypoint.new(0, Color3.fromRGB(255,255,255)),
ColorSequenceKeypoint.new(1, Color3.fromRGB(197,197,197))
})
end
