for _, data in ButtonsHandler do
for _, Button in Buttons:GetDescendants() do
if Button:IsA("BasePart") and not Debounce then
Debounce = true
local Clone = ButtonStatsGui:Clone()
Clone.Parent = Button
local stat = data["Stat"]
local nextStat = data["NextStat"]
local amount = data["Amount"]
local cost = data["Cost"]
local Frame = Button.ButtonStats.Frame
local Amount = Frame.Amount
local Cost = Frame.Cost
Amount.Text = amount.." "..nextStat
Cost.Text = cost.." "..stat
Button.Button.Touched:Connect(function(hit)
if hit.Parent:FindFirstChildOfClass("Humanoid") then
local Player = Players:GetPlayerFromCharacter(hit.Parent)
if Player then
local cash = Player.leaderstats.Cash
local multi = Player.leaderstats.Multiplier
local rebirths = Player.leaderstats.Rebirths
if stat == "Robux" then
-- Buy Robux / Gamepass
elseif stat == "Cash" then
if cash.Value >= cost then
cash.Value -= cost
multi.Value += amount
end
elseif stat == "Multi" then
if multi.Value >= cost then
multi.Value -= cost
rebirths.Value += amount
end
end
task.wait(0.2)
Debounce = false
end
end
end)
end
end
end
Correct me if I’m wrong, but could this be because of the debounce? By what I see, only one button might be activated (due to the Debounce variable immediately being changed at the start of the loop). Make sure to use the debounce after the button is touched, not before (although with the current way this is written, only one button should be active at a time due to the debounce).
Additionally, being descriptive regarding your problem helps whoever is trying to figure it out by a lot. Hope this helps!
for _, data in ButtonsHandler do
for _, Button in Buttons:GetDescendants() do
if Button:IsA("BasePart") and not Debounce == true then
Debounce = true
local Clone = ButtonStatsGui:Clone()
Clone.Parent = Button
local stat = data["Stat"]
local nextStat = data["NextStat"]
local amount = data["Amount"]
local cost = data["Cost"]
local Frame = Button.ButtonStats.Frame
local Amount = Frame.Amount
local Cost = Frame.Cost
Amount.Text = amount.." "..nextStat
Cost.Text = cost.." "..stat
Button.Button.Touched:Connect(function(hit)
if hit.Parent:FindFirstChildOfClass("Humanoid") then
local Player = Players:GetPlayerFromCharacter(hit.Parent)
if Player then
local cash = Player.leaderstats.Cash
local multi = Player.leaderstats.Multiplier
local rebirths = Player.leaderstats.Rebirths
if stat == "Robux" then
-- Buy Robux / Gamepass
elseif stat == "Cash" then
if cash.Value >= cost then
cash.Value -= cost
multi.Value += amount
end
elseif stat == "Multi" then
if multi.Value >= cost then
multi.Value -= cost
rebirths.Value += amount
end
end
task.wait(0.2)
Debounce = false
end
end
end)
end
end
end
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Objects = ReplicatedStorage.Objects.GUI.Other
local Configs = ReplicatedStorage.Modules.Client.Configs
local ButtonsHandler = require(Configs.ButtonsConfig)
local ButtonStatsGui = Objects.ButtonStats
local Buttons = workspace.Buttons
for _, data in ButtonsHandler do
for _, Button in Buttons:GetDescendants() do
if Button:IsA("BasePart") then
local Clone = ButtonStatsGui:Clone()
Clone.Parent = Button
local stat = data["Stat"]
local nextStat = data["NextStat"]
local amount = data["Amount"]
local cost = data["Cost"]
local Frame = Button.ButtonStats.Frame
local Amount = Frame.Amount
local Cost = Frame.Cost
Amount.Text = amount.." "..nextStat
Cost.Text = cost.." "..stat
Button.Button.Touched:Connect(function(hit)
if hit.Parent:FindFirstChildOfClass("Humanoid") then
local Player = Players:GetPlayerFromCharacter(hit.Parent)
if Player then
local cash = Player.leaderstats.Cash
local multi = Player.leaderstats.Multiplier
local rebirths = Player.leaderstats.Rebirths
if stat == "Robux" then
-- Buy Robux / Gamepass
elseif stat == "Cash" then
if cash.Value >= cost then
cash.Value -= cost
multi.Value += amount
end
elseif stat == "Multi" then
if multi.Value >= cost then
multi.Value -= cost
rebirths.Value += amount
end
end
end
end
end)
end
end
end