Hello, so i made a script which checks if value increased and how much it increased, then it pops up as a gui in the corner! however this only works when the value is increased! How can i check if the value decreased and make it pop out in gui that it decreased??
script:
local plr = game.Players.LocalPlayer
local stats = plr:FindFirstChild("leaderstats")
local Cash = plr:WaitForChild("leaderstats").Cash -- Gets the Value Object
local CurrentPoints = plr:WaitForChild("leaderstats").Cash.Value -- Gets the current number of the
Points
local debounce = false
Cash:GetPropertyChangedSignal("Value"):Connect(function() if debounce == false then
if stats then
if Cash.Value > CurrentPoints then
local prev = stats.Cash.Value
stats["Cash"].Changed:Connect(function()
local MoneyText = script.Parent.MoneyUpdate:Clone()
MoneyText.Parent = script.Parent
MoneyText.Visible = true
MoneyText.Text ="+".. (stats["Cash"].Value-prev) .. "$"
MoneyText.Position = UDim2.new(0.778, 0, 0.869, 0)
script.Parent["Collecting-Money"]:Play()
local random = math.random(1, 3)
if random == 1 then
MoneyText:TweenPosition(UDim2.new(0.778,0,0.7,0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, 0.5, false)
elseif random == 2 then
MoneyText:TweenPosition(UDim2.new(0.778,0,0.74,0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, 0.5, false)
elseif random == 3 then
MoneyText:TweenPosition(UDim2.new(0.778,0,0.72,0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, 0.5, false)
end
MoneyText.TextColor3 = Color3.new(0, 0.658824, 0)
prev = stats.Cash.Value
print(stats["Cash"].Value)
wait(0.8)
MoneyText.Visible = false
MoneyText:Destroy()
debounce = true
end)
end
end
end
end)