Hello! I have made a gui, witch show’s your coins value, but it don’t update’s
Code:
local parent = script.Parent
local Value = game.Players.LocalPlayer.leaderstats.Coins.Value
function renew()
if Value >= 1000 and Value < 1000000 then
parent.Text = Value /1000
parent.Text = (math.floor(parent.Text * 10))/10 .. "K"
elseif Value >= 1000000 and Value < 1000000000 then
parent.Text = Value /1000000
parent.Text = (math.floor(parent.Text * 10))/10 .. "M"
elseif Value >= 1000000000 and Value < 1000000000000000000000000000000000000 then
parent.Text = Value /10000
parent.Text = "inf"
end
if Value >= 0 and Value < 1000 then
parent.Text = Value
end
end
while true do
wait(1)
renew()
end
local parent = script.Parent
--define the reference to the object, not the value itself(else it remains constant)
local Coins = game.Players.LocalPlayer.leaderstats.Coins
function floor(num, decimalDigits)
local x = 10^decimalDigits
return math.floor(num*x)/x
end
local multipliers = {"K", "M", "B", "T"}
function Convert(number)
local negative = (number < 0)
number = math.abs(number)
local multiplier, name = 1, ""
for i, v in ipairs(multipliers) do
local raised = 1000^i
if raised > multiplier and raised <= number then
multiplier, name = raised, v
end
end
local result = floor(number/multiplier, 1)
if negative then
result = -result
end
return result..name
end
function CoinsChanged(value)
parent.Text = Convert(value)
end
CoinsChanged(Coins.Value)
Coins.Changed:Connect(CoinsChanged)