I have an error with this script:
local Players = game:GetService("Players")
local plr = script.Parent.Parent.Parent
local leaderstats = plr:WaitForChild("leaderstats")
local cur = "Cash"
local Coins = leaderstats:WaitForChild(cur)
local dif = Coins.Value
local suffixes = {'','K','M','B','T','qd','Qn','sx','Sp','O','N','de','Ud','DD','tdD','qdD','QnD','sxD','SpD','OcD','NvD','Vgn','UVg','DVg','TVg','qtV','QnV','SeV','SPG','OVG','NVG','TGN','UTG','DTG','tsTG','qtTG','QnTG','ssTG','SpTG','OcTG','NoAG','UnAG','DuAG','TeAG','QdAG','QnAG','SxAG','SpAG','OcAG','NvAG','CT'}
local function format(val)
for i=1, #suffixes do
if tonumber(val) < 10^(i*3) then
return math.floor(val/((10^((i-1)*3))/100))/(100)..suffixes[i]
end
end
end
Coins.Changed:Connect(function(NewValue)
if NewValue - dif > 0 then
local random = math.random(1, 900)
local xnew = random / 1000
local new = script:WaitForChild(cur):Clone()
new:WaitForChild(cur.."Info").Text = (format(NewValue - dif)) --Error Here
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.025, 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
print("Lost "..(NewValue - dif)..": Amount of Money")
end
end)
Video:
It gives me 1k in the leaderstats but it shows in screen it gives me 2k and some times 3k
How to fix it?
Sry my pc sucks and My pants got deleted