My script (maybe) assumes that the yes/no button in a Gui in PlayerGui was clicked even before the gui appears. Script:
for i = 1e+18, 1, -1 do wait(.5) print(i .. " Showing debts..") if taxYes.MouseButton1Down or taxNo.MouseButton1Down then break end end if taxYes.MouseButton1Down or taxNo.MouseButton1Down then wait(2) unpaid_tax = unpaid_tax_datastore:GetAsync(player.UserId) unpaid_tax_storage = unpaid_tax_datastorage:GetAsync(player.UserId) debt = ((0 - plrInDebt.leaderstats.Cash.Value) + unpaid_tax or unpaid_tax_storage) debtAmount.Text = "$" .. debt end
I'll edit the question if you have a problem concerning the other scripts which are very long.
Okay so, I put a local script inside of a text button, and pasted this:
if script.Parent.MouseButton1Click then print("Clicked.") end
And, when I ran it, the game printed "Clicked" as soon as I joined if even if I clicked it or not.
To fix this, use:
script.Parent.MouseButton1Click:Connect(function() print("Clicked.") end
Another thing is, you don't need to do a loop at all.
Here's the final code:
local function Clicked() taxYes.MouseButton1Down:Connect(function() return true end) taxNo.MouseButton1Down:Connect(function() return true end) end if Clicked() == true then wait(2) unpaid_tax = unpaid_tax_datastore:GetAsync(player.UserId) unpaid_tax_storage = unpaid_tax_datastorage:GetAsync(player.UserId) debt = ((0 - plrInDebt.leaderstats.Cash.Value) + unpaid_tax or unpaid_tax_storage) debtAmount.Text = "$" .. debt end