I am trying to make a GUI that shows how much money you collected/lost when it happens (example below) but I am having trouble trying to figure out how I am going to grab that value.
If you could provide an example of how I could do this that would be appreciated.
You’d need to store the previous value before it was changed as the example above demonstrated, to log all changes you could do the following.
local value = workspace.Value --Example value instance.
local oldValues = {}
value.Changed:Connect(function(newValue)
print("Value changed from "..oldValues[#oldValues].." to "..newValue.."!")
table.insert(oldValues, newValue)
end)
local value = workspace.Value
local last_value = value.Value
value:GetPropertyChangedSignal("Value"):Connect(function()
local difference = value.Value - last_value
local prefix = value.Value < last_value and "-" or "+"
local text = prefix..difference
print(text) -- if the value was subtracted by 5 it should print "-5"
last_value = value.Value
end)