is there a way for me to turn for every item in the table
tableexample = {
tblex1 = "rbxassetid://123",
tblex2 = "rbxassetid://456",
tblex3 = "rbxassetid://789",
}
--not my actual script cus im still brainstorming how it would look like
into a instance button that can be compatible with “:Connect(function()” ?
im sorry if it sounds like a bunch’o gargle im very new to scripting
for _, id in arrayOfIds do
local button = Instance.new("ImageButton")
button.Image = id
-- set position, size, and parent to whatever you want
button.Activated:Connect(function()
-- button gets clicked
end)
end
Yes, you can loop the table and create instances using it.
Example code:
local tableexample = {
tblex1 = "rbxassetid://123",
tblex2 = "rbxassetid://456",
tblex3 = "rbxassetid://789",
}
local function CreateButton(imageId)
local newButton = Instance.new("ImageButton")
newButton.Image = imageId
newButton.Parent = script.Parent
newButton.MouseButton1Down:Connect(function()
print("MouseDown")
end)
end
for i, imageId in pairs(tableexample) do
CreateButton(imageId)
end