heres the problem, i want to print the changed value, for example when you add 30 to the player cash it prints the added number which should be 30+ , just a record for every added number to a value.
Just cache the old value so you can calculate the difference:
local oldValue = Cash.Value
Cash.Changed:Connect(function(value) --.Changed fires on value change
local diff = value-oldValue
oldValue = value
print(diff)
end)
--example, 50 should be printed
Cash.Value += 50
1 Like
thank you very much for your help
any one who is curious on how to find if the value has been subtracted from or added then this is the script
local oldValue = game.Players.LocalPlayer.leaderstats.Cash.Value
game.Players.LocalPlayer.leaderstats.Cash.Changed:Connect(function(value) --.Changed fires on value change
local diff = value-oldValue
oldValue = value
print(diff)
if diff < 0 then
script.Parent.Text = diff
script.Parent.TextColor3 = Color3.fromRGB(255, 0, 0)
elseif oldValue > diff then
script.Parent.Text = "+".. diff
script.Parent.TextColor3 = Color3.fromRGB(0, 255, 0)
end
end)
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.