Basically whenever a players data has changed, this function is fired and the goal of the ‘OriginalCoins’ is to basically see how much coins they spent.
So the idea behind this was to see how many coins the player originally had, minus their coins now and that would show how much coins they spent right. However I get a problem if I buy a ton of stuff at once, it adds up
As you can see in the red text, it keeps adding 5 everytime I buy an item (in quick succession) However the item only costs 5 coins. So it should say -5 5 times
local function updateData(data)
if not OriginalCoins then
OriginalCoins = data.Coins
end
CoinsAmount.Text = data.Coins
if OriginalCoins > data.Coins then
local NewCoins = Instance.new('TextLabel')
NewCoins.BackgroundTransparency = 1
NewCoins.Size = UDim2.new(1, 0, 0.25, 0)
NewCoins.Font = 'GothamBlack'
NewCoins.TextColor3 = Color3.fromRGB(255, 50, 50)
NewCoins.Text = '-' .. OriginalCoins - data.Coins
NewCoins.TextScaled = true
NewCoins.TextXAlignment = 'Left'
NewCoins.Parent = CoinsSpent
wait(3)
NewCoins:Destroy()
end
if OriginalCoins > data.Coins then
OriginalCoins = data.Coins
end
end