NumberValue Addition = 1
IntValues Multiplier = 1 Adder = 1
This script is in an Image Button
wait(0.6)
addv = script.Parent.Parent.LemonBuy.Addition.Value
multiv = script.Parent.Parent.LemonBuy.Multiplier.Value
button = script.Parent
ting = 0
function onClick()
if ting == 0 then --debounce check
ting = 1 --activate debounce
local plr=script.Parent.Parent.Parent.Parent.Parent
local stats=plr:FindFirstChild('leaderstats')
if stats ~= nil then --If moneyholder exists then
local cash = stats:findFirstChild("Money") --Get money
cash.Value = cash.Value +(addv*multiv)
wait(0.8) --wait-time before button works again
end
ting = 0 --remove debounce
end
end
button.MouseButton1Click:connect(onClick)
Connecting with this is another script... This script is in a TextButton.
wait(0.6)
local cost = Instance.new("NumberValue")
cost.Value = 4
costv = cost.Value
local plr=script.Parent.Parent.Parent.Parent.Parent
local stats=plr:FindFirstChild('leaderstats')
local money=stats:FindFirstChild('Money')
local multi = Instance.new("NumberValue")
multi.Value = 1.00
multiv = multi.Value
print("Run 1")
addv = script.Parent.Addition.Value
adder = script.Parent.Adder
button = script.Parent
ting = 0
function onClick()
if ting == 0 then --debounce check
ting = 1 --activate debounce
local stats=plr:FindFirstChild('leaderstats')
if stats ~= nil then --If moneyholder exists then
local money=stats:FindFirstChild('Money') --Get money
if money.Value>=costv then
money.Value = money.Value - costv
costv = costv * (multiv+0.07)
addv = addv + adder.Value
end --increase amount of money by the number displayed here (500)
wait() --wait-time before button works again
end
ting = 0 --remove debounce
end
end
button.MouseButton1Click:connect(onClick)
function force_decimal_places(num, places)
if type(num) ~= 'number' or type(places) ~= 'number' then
return 'NaN' --not a number
end
local mult = 10^(places or 0) --set up rounding places
num = tostring( math.floor(num * mult + 0.5) / mult ) --round
local dot = string.find(num, '%.')
if not dot then --easily add zeros to an integer
num = num..'.'..string.rep('0', places)
else --some after decimal?
local after = string.sub(num, dot + 1)
if after ~= places then --if it doesn't already round to exact places
num = num..string.rep('0', places - #after)
end
end
return num --returns a string (otherwise the zeros would get truncated)
end
print("Run 3")
while wait(0.1) do
local dollars2 = force_decimal_places(costv, 2)
script.Parent.Text = 'Buy: $'..dollars2
end
print("Run 4")

1 comment
See these questions: https://scriptinghelpers.org/questions/11524/value-not-changing-correctly-solved https://scriptinghelpers.org/questions/14928/why-is-the-numbervalue-not-updating