local dialog= script.Parent
local values= script.Parent.Parent.Parent.Parent.Values
dialog.DialogChoiceSelected:connect(function(player, choice)
-- Check the player has a stats object
local stats = player:FindFirstChild('leaderstats')
if not stats then return end
local Cash = stats:FindFirstChild('Cash')
if not Cash then return end
if choice == script.Parent.Building.Panel1 then
if values.Panel1.Value==false then
if Cash.Value >= 500 then
values.Panel1.Value=true
Cash.Value = Cash.Value - 500
elseif Cash.Value <=500 then
script.Parent.Building.Panel1.ResponseDialog=("Sorry, you don't have the cash!")
end
end
end
end)
Looks fine, no errors in output... But it acts as if cash is always at or above 500. Even when cash is obviously lower than 500, it still doesn't properly change the dialog. Did I mess something up? |