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
script.Parent.TextLabel.Text = ""..Player.leaderstats.Money.Value
end
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
script.Parent.TextLabel.Text = ""..Player.leaderstats.Money.Value
end
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
script.Parent.TextLabel.Text = v1(player:WaitForChild("leaderstats").Money.Value)
end
This should do it. I don’t understand half of it, but it works perfectly
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
script.Parent.TextLabel.Text = v1(player:WaitForChild("leaderstats").Money.Value)
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)
script.Parent.TextLabel.Text = v1(player:WaitForChild("leaderstats").Money.Value)
end)
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
player:WaitForChild('leaderstats').Money.Changed:Connect(function()
script.Parent.TextLabel.Text = v1(player:WaitForChild("leaderstats").Money.Value)
end)
Yeah while wait() do
is like 1/30 second, and while task.wait() do
is instant.
So we can do:
while task.wait(1/30) or task.wait(0.033333333333333333333333333333333) do
-- Anything
end
But the best way to do it probably:
while task.wait(1/30) do
--Anything you want to put, here.
end
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()
script.Parent.TextLabel.Text = v1(player:WaitForChild("leaderstats").Money.Value)
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
while true do
-- Code
task.wait()
end
Im so confused rn, I have three different scripters telling me what to do… Which one’s the right one?
The function I gave u is correct.
We just gave u 3 ways to update ur text.