I’m trying to check how much a value has gone up using .Changed event but it shows the current (or how much value is overall) despite me only trying to check HOW much it gone up not what it is new value
Lets for say a player TIX has gone up by 500 and i’m trying to make it show up as a text but it’s only showing how much the player has now (like for example 1500)
local __TEXT = script.Parent
local __TIX = game.Players.LocalPlayer.leaderstats.__TIX -- Player for example has 1000 tix
__TIX.Changed:Connect(function(__NEWVAL)
__TEXT.Text = "+T$"..__NEWVAL-- Should show the value has gone up by 500 not show 1500.
game:GetService("TweenService"):Create(__TEXT , TweenInfo.new(1), {TextTransparency = 0}):Play()
task.wait(3)
game:GetService("TweenService"):Create(__TEXT , TweenInfo.new(1), {TextTransparency = 1}):Play()
end)
You can try to store the original value of the TIX and compare it with the new value whenever it changes. This way you can get the difference between the original and new value and show the number of TIX has gone up.
(This is an example)
local __TEXT = script.Parent
local __TIX = game.Players.LocalPlayer.leaderstats.__TIX -- Player for example has 1000 tix
local __ORIGINAL_TIX = __TIX.Value
__TIX.Changed:Connect(function(__NEWVAL)
local __DIFFERENCE = __NEWVAL - __ORIGINAL_TIX
__TEXT.Text = "+T$"..__DIFFERENCE
game:GetService("TweenService"):Create(__TEXT , TweenInfo.new(1), {TextTransparency = 0}):Play()
task.wait(3)
game:GetService("TweenService"):Create(__TEXT , TweenInfo.new(1), {TextTransparency = 1}):Play()
end)
Also the use of variables make it really hard to read ur code.