local Buttons = {
"Button1",
"Button2",
"Button3"
}
local function RemoveMoney(holder)
if Money.Value - holder.Price <= -1 do
return
else
Money.Value -= holder.Price
end
end
for i = 1, #Buttons do
local Holder = Module:FindFirstChild(Buttons[i])
Holder.ButtonGUI.Activated:Connect(RemoveMoney)(Holder)
end
Maybe something like this could work, alternatively you could just loop through module and ofc have the right checks and should work out the same.
local function RemoveMoney(Holder)
Money.Value -= (Money.Value - Holder.Price <= -1) and Holder.Price or 0
end
for _, ButtonHolder in Module:GetChildren() do
if not ButtonHolder:IsA("Frame") then continue end -- Assuming the buttons are Frames holding TextButtons
-- You can't pass arguments like how you did
-- Rename ButtonGui -> Button
ButtonHolder.Button.Activated:Connect(function() RemoveMoney(Button) end)
end
Yes so the module is the modulescript table thats in a module script that’s inside replicated storage,
this is what the code in the modulescript looks like:
local function RemoveMoney(Holder)
if Money.Value - holder.Price <= -1 do
return
else
Money.Value -= holder.Price
end
end
for ButtonName, ButtonInfo in module do
local Button = ButtonInfo.ButtonGUI
Button.Activated:Connect(function()
RemoveMoney(Button)
end)
end