Im trying to make a system that puts a gui on the players screen that tells how much money the player has lost or earned, but GetPropertyChangedSignal is being wierd its displaying the players full balance instead of the normal added or removed value. This bug also only happens the first few times that the players balance is changed for some reason.
Script:
local plr = game.Players.LocalPlayer
local leaderstats = plr:WaitForChild("leaderstats")
local money = leaderstats:WaitForChild("Dabloons")
local currentamount = money.Value
local label = script.Parent.Label
wait(1)
money:GetPropertyChangedSignal("Value"):Connect(function()
if money.Value < currentamount then
local changed = currentamount - money.Value
local c = label:Clone()
c.Position = UDim2.fromScale(math.random(), (math.random()/2)+0.5)
c.TextTransparency = 0
c.Text = "-" .. changed
c.TextColor3 = Color3.new(1, 0.360784, 0.360784)
c.Parent = script.Parent
--wait(0.5)
game:GetService("TweenService"):Create(c,TweenInfo.new(2),{TextTransparency = 1}):Play()
--game:GetService("TweenService"):Create(c,TweenInfo.new(2),{Position = UDim2.fromScale(c.Position.X,c.Position.Y+2)}):Play()
c:TweenPosition(UDim2.new(c.Position.X,50),Enum.EasingDirection.InOut,Enum.EasingStyle.Linear,2)
wait(2)
c:Destroy()
elseif money.Value > currentamount then
local changed = money.Value - currentamount
local c = label:Clone()
c.Position = UDim2.fromScale(math.random(), (math.random()/2)+0.5)
c.TextTransparency = 0
c.Text = "+" .. changed
c.TextColor3 = Color3.new(0.341176, 1, 0.396078)
c.Parent = script.Parent
--wait(0.5)
game:GetService("TweenService"):Create(c,TweenInfo.new(2),{TextTransparency = 1}):Play()
--game:GetService("TweenService"):Create(c,TweenInfo.new(2),{Position = UDim2.fromScale(c.Position.X,c.Position.Y+2)}):Play()
c:TweenPosition(UDim2.new(c.Position.X,50),Enum.EasingDirection.InOut,Enum.EasingStyle.Linear,2)
wait(2)
c:Destroy()
end
currentamount = money.Value
end)