# How to add a "k" after coins reach a thousand

Hi

How do I add a “K” to my coins if they reach a thousand, so they show up as 1K and not 1000

local Player = game.Players.LocalPlayer

while wait() do
end
3 Likes

try doing an if statement if the player reaches 1000+. Hope this helps

local u1 = {"", 'K', "M", "B", "T", "Qa", "Qi", "Sx", "Sp", "Oc", "No", "Dc"}
function v1(p1)
for v2 = 1, #u1 do
if tonumber(p1) < 10 ^ (v2*3) then
return math.floor(p1/(10^((v2-1)*3)/100))/100 .. u1[v2]
end
end
end

local player = game.Players.LocalPlayer
while wait() do
end

This should do it. I don’t understand half of it, but it works perfectly

5 Likes

Don’t forget the end or else that’ll constantly error if you don’t put end after do, then (Except elseif), (function(ANY_NAME) and local function YOUR_NAME_HERE_TO_THE_FUNCTION().

local u1 = {"", 'K', "M", "B", "T", "Qa", "Qi", "Sx", "Sp", "Oc", "No", "Dc"}
function v1(p1)
for v2 = 1, #u1 do
if tonumber(p1) < 10 ^ (v2*3) then
return math.floor(p1/(10^((v2-1)*3)/100))/100 .. u1[v2]
end
end
end

local player = game.Players.LocalPlayer
while wait() do
end

Edit: He edited the script to in final, add the missing end after “while wait() do”.

the while wait would lag the script just do

script.Parent.TextLabel:GetPropertyChangegSignal('Text'):Connect(function)

then format code

end)

So What would the full script look like?

While wait do is bad practice as wait is deprecated and replaced with task.wait and theres a chance (apparently) wait/task.wait can return nil stopping the while loop
You should instead do while true do and at the end of the code put task.wait()

What would it look like the code?

That is the full script. Just add that function in ur code

it would be

local u1 = {"", 'K', "M", "B", "T", "Qa", "Qi", "Sx", "Sp", "Oc", "No", "Dc"}
function v1(p1)
for v2 = 1, #u1 do
if tonumber(p1) < 10 ^ (v2*3) then
return math.floor(p1/(10^((v2-1)*3)/100))/100 .. u1[v2]
end
end
end

local player = game.Players.LocalPlayer
script.Parent.TextLabel:GetPropertyChangegSignal('Text'):Connect(function)
end)

I get this underline rror:

actually it would be:

local u1 = {"", 'K', "M", "B", "T", "Qa", "Qi", "Sx", "Sp", "Oc", "No", "Dc"}
function v1(p1)
for v2 = 1, #u1 do
if tonumber(p1) < 10 ^ (v2*3) then
return math.floor(p1/(10^((v2-1)*3)/100))/100 .. u1[v2]
end
end
end

local player = game.Players.LocalPlayer

end)

1 Like

Yeah while wait() do is like 1/30 second, and while task.wait() do is instant.

So we can do:

-- Anything
end

But the best way to do it probably:

--Anything you want to put, here.
end
1 Like

Oh, I know why.

local u1 = {"", 'K', "M", "B", "T", "Qa", "Qi", "Sx", "Sp", "Oc", "No", "Dc"}
function v1(p1)
for v2 = 1, #u1 do
if tonumber(p1) < 10 ^ (v2*3) then
return math.floor(p1/(10^((v2-1)*3)/100))/100 .. u1[v2]
end
end
end

local player = game.Players.LocalPlayer
script.Parent.TextLabel:GetPropertyChangegSignal('Text'):Connect(function()
end)

Sorry for spam.

HI, Are you certain? I just want to be 100% sure

yes that is what I use in a formater

while loops are bad in general as they can make so much lag so only really use them if necessary

1 Like
while true do
-- Code