functions to gradually increase/decrease transparency of a textlabel:
function appear(label)
print("appear function called")
for i = 1, 0, -.1 do
label.TextTransparency = i
label.TextStrokeTransparency = i
wait()
end
end
function disappear(label)
print("disappear function called")
for i = 0, 1, .1 do
label.TextTransparency = i
label.TextStrokeTransparency = i
wait()
end
end
main script:
db = 0
visible = false
playerOwnsOrange = false
script.Parent.MainFrame.AppearanceF.ColorF.Orange.MouseButton1Click:Connect(function()
local price = 2000
local lp = game.Players.LocalPlayer
local cash = lp:findFirstChild("leaderstats").Cash
local bank = lp:findFirstChild("leaderstats").Bank
if playerOwnsOrange == true then --if player already bought this
print("PlayerOwnsOrange; money not deducted")
CarThatTouched.Body.CarBody.CarColor.Color = Color3.fromRGB(235, 131, 39)
script.Parent.MainFrame.AppearanceF.ColorF.Color.Text = "Color: Orange"
elseif cash.Value >= price and playerOwnsOrange == false then
cash.Value = cash.Value - price --deducts money
playerOwnsOrange = true
if db == 0 then --(everything works up until here) makes textlabel appear using functions defined above
print("test") -- NOT PRINTED
db = 1
local plrgui = lp:findFirstChild("PlayerGui")
local mc = plrgui.ChangeOfMoney.MoneyChangeFrame.MoneyChange
if visible == false then
mc.Text = "-$"..price
appear(mc)
visible = true
print("CoM visible")
wait(4)
disappear(mc)
visible = false
db = 0
elseif visible == true then
print("com visible")
disappear(mc)
db = 0
end
end
CarThatTouched.Body.CarBody.CarColor.Color = Color3.fromRGB(235, 131, 39)
script.Parent.MainFrame.AppearanceF.ColorF.Color.Text = "Color: Orange"
script.Parent.MainFrame.AppearanceF.ColorF.Orange.Text = ""
there are "end"s, just later in the script

6 comments
Try 'if db < 1 then'
Or just simply use Bools.
Same result
Try changing the variable from db = 0 to local db = 0
Local variables are used so the variable is only used in a certain function that it can only be seen from that function. Putting local on db would do noting since it would just means that it can be used in the whole script which is the same regardless without 'local'.
The "if" function won't work if the "elseif" is false?