http://cdn.discordapp.com/attachments/449312711969603594/729053356361777242/2020-07-04_15-16-00.mp4
A preview of the bug, whenever I step on the button when I dont have enough cash, and then wait till I get enough, the button wont trigger the function, but whenever I dont step on the button, and when I have cash it works.
local buttonConfig = script.Parent.Parent.Configuration
local config = script.Parent.Parent.Parent.Parent:WaitForChild("Configuration")
local ButtonFolder = script.Parent.Parent.Parent.Parent:WaitForChild("Buttons")
local Items = script.Parent.Parent.Parent.Parent:WaitForChild("Items")
local tycoonName = script.Parent.Parent.Parent.Parent.Name
local itemsStorage = game.Lighting[tycoonName].ItemsStorage
local item = itemsStorage:FindFirstChild(buttonConfig.Unlock.Value)
local buttonsStorage = game.Lighting[tycoonName].ButtonsStorage
local buttons = buttonsStorage:FindFirstChild(buttonConfig.UnlockButton.Value)
local setting = require(script.Parent.Parent.Parent.Parent.Parent.Parent:WaitForChild("Settings"))
function ButtonShow()
buttons.Parent = ButtonFolder
buttons.Head.PurchaseHandler.Disabled = false
end
local buttonPressed = false
function onTouch(button)
local player = game.Players:GetPlayerFromCharacter(button.Parent)
local stat = player:WaitForChild("leaderstats")
local owns = player:WaitForChild("Owns")
local cash = game.Lighting[owns.Value].CashStorage[setting.LeaderboardSettings.CurrencyName]
if player ~= nil then
if button and button.Parent and button.Parent:FindFirstChild("Humanoid") then
if player and config.Owner.Value == player then
if not buttonPressed then
buttonPressed = true
if cash.Value >= buttonConfig.Price.Value then
cash.Value = cash.Value - buttonConfig.Price.Value
item.Parent = Items
script.Parent.Transparency = 1
script.Parent.CanCollide = false
script.Parent.BillboardGui:Destroy()
wait(1)
buttonPressed = false
if buttonConfig.UnlockButton.Value == "" then
else
ButtonShow()
end
script.Parent.Parent:Destroy()
end
end
end
end
end
end
script.Parent.Touched:connect(onTouch)
