I have a big problem with this script!

  1. What do you want to achieve?

A working Coins pop up that shows the value increasing and if the value decreases that doesn’t show but if you get more it won’t show until you get back to the number you left off from!

  1. What is the issue?

The Coins pop up shows the value increasing and if the value decreases that doesn’t show but if you get more it won’t show until you get back to the number you left off from!

  1. What solutions have you tried so far?

Finding a solution!

Thank you in advance!

local Players = game:GetService("Players")
local plr = script.Parent.Parent.Parent
local leaderstats = plr:WaitForChild("leaderstats")
local Coins = leaderstats:WaitForChild("Coins")
local module = require(game.ReplicatedStorage.Abbreviations)
local dif = Coins.Value

Coins.Changed:Connect(function(NewValue)
	if NewValue - dif > 0 then -- this starts when player gets money
		local random = math.random(1, 900)
		local xnew = random / 1000
		local new = script:WaitForChild("Coins"):Clone()
		new:WaitForChild("CoinsInfo").Text = "+"..module.abbreviate(NewValue - dif)
		local NewRandom = Random.new()
		new.Position = UDim2.new(NewRandom:NextNumber(0, 0.9), 0, NewRandom:NextNumber(0, 0.9), 0)
		new.Parent = script.Parent
		dif = Coins.Value
		local TweenService = game:GetService("TweenService")

		local tween = TweenService:Create(new, TweenInfo.new(1), {Rotation = 360})

		task.wait(1)
		new:TweenSize(UDim2.new(0.056, 0, 0.099, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Quart, 0.3, true)
		task.wait(0.3)
		new:TweenPosition(UDim2.new(0.03, 0,0.305, 0),Enum.EasingDirection.In,Enum.EasingStyle.Linear,0.2)
		task.wait(0.2)
		new:TweenSize(UDim2.new(0, 0, 0, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Quart, 0.3, true)
		task.wait(0.2)

		new.Parent = nil
		dif = NewValue
	elseif dif - NewValue < 0 then -- when player lose money
		print("Lost "..(NewValue - dif)..": Amount of Money")
	end
end)

Thank you in advance!

Maybe moving the line

dif = NewValue

after the if-statement would work?