So I created this script, which includes a sub table called buttons, which has button tables, and within those button tables is information about the button, such as the text and what it does when pushed. My problem is that I’m attempting to change the text that appears when the button is pressed, but I’m not sure where to put the colon to make the table the first parameter or how to alter the real gui button text. I’ve done some research and haven’t been able to find what I’m searching for, so I’d appreciate it if someone could assist me with this. My code is as follows:
local Player = game:GetService("Players").LocalPlayer
Table = {
["Buttons"] = {
[1] = {
["Text"] = "Click Me!",
["Function"] = function() -- How do I use a colon here? And how would I make the text update
self.Text = "Thank you for clicking me!"
end
},
[2] = {
["Text"] = "Click Me! (2)",
["Function"] = function()
self.Text = "Thank you for clicking me! (2)"
end
}
}
}
local ScreenGui = Instance.new("ScreenGui", Player:WaitForChild("PlayerGui"))
for i, v in ipairs(Table.Buttons) do
local Button = Instance.new("TextButton", ScreenGui)
Button.Text = v.Text
Button.MouseButton1Click:Connect(function()
v:Function() -- Doesn't work
end)
end