This is my code:
local am = player:WaitForChild("CashRecieved").Value script.Parent.Text = "$"..player:WaitForChild("CashRecieved").Value player:WaitForChild("CashRecieved").Changed:Connect(function() script.Parent.Text = "$"..player:WaitForChild("CashRecieved").Value if player:WaitForChild("CashRecieved").Value == 1000 then script.Parent.Text = "1,000" else if player:WaitForChild("CashRecieved").Value == 1100 then script.Parent.Text = "1,100" elseif player:WaitForChild("CashRecieved").Value == 1200 then script.Parent.Text = "1,200" elseif player:WaitForChild("CashRecieved").Value == 1300 then script.Parent.Text = "1,300" else if player:WaitForChild("CashRecieved").Value == 1400 then script.Parent.Text = "1,400" elseif player:WaitForChild("CashRecieved").Value == 1500 then script.Parent.Text = "1,500" elseif player:WaitForChild("CashRecieved").Value == 1600 then script.Parent.Text = "1,600" else if player:WaitForChild("CashRecieved").Value == 1700 then script.Parent.Text = "1,700" elseif player:WaitForChild("CashRecieved").Value == 1800 then script.Parent.Text = "1,800" elseif player:WaitForChild("CashRecieved").Value == 1900 then script.Parent.Text = "1,900" else if player:WaitForChild("CashRecieved").Value == 2000 then script.Parent.Text = "2,000" elseif player:WaitForChild("CashRecieved").Value == 2100 then script.Parent.Text = "2,100" elseif player:WaitForChild("CashRecieved").Value == 2200 then script.Parent.Text = "2,200" else if player:WaitForChild("CashRecieved").Value == 2300 then script.Parent.Text = "2,300" elseif player:WaitForChild("CashRecieved").Value == 2400 then script.Parent.Text = "2,400" elseif player:WaitForChild("CashRecieved").Value == 2500 then script.Parent.Text = "2,500" else if player:WaitForChild("CashRecieved").Value == 2600 then script.Parent.Text = "2,600" elseif player:WaitForChild("CashRecieved").Value == 2700 then script.Parent.Text = "2,700" elseif player:WaitForChild("CashRecieved").Value == 2800 then script.Parent.Text = "2,800" elseif player:WaitForChild("CashRecieved").Value == 2900 then script.Parent.Text = "2,900" elseif player:WaitForChild("CashRecieved").Value == 3000 then script.Parent.Text = "3,000" end end end end end end end end)
local am = player:WaitForChild("CashRecieved").Value script.Parent.Text = "$"..player:WaitForChild("CashRecieved").Value local CashRecievedValue = player:WaitForChild("CashRecieved") CashRecievedValue.Changed:connect(function(difference) local value = tostring(CashRecievedValue.Value) -- converts the CashRecievedValue to string if string.sub(value, 2, 4) == "000" then -- checks if last three digits of the value is '000' ex: 3000 script.Parent.Text = value elseif string.sub(value, 3, 4) == "00" then -- checks if last two digits of the value is '00' ex: 1100 script.Parent.Text = value end end)
-- from sam_lie -- Compatible with Lua 5.0 and 5.1. -- Disclaimer : use at own risk especially for hedge fund reports :-) ---============================================================ -- add comma to separate thousands -- function comma_value(amount) local formatted = amount while true do formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2') if (k==0) then break end wait() -- I added this because in regular Lua there is no wait function end return formatted end
Hi, instead of using so many else if's, just use a while true do loop to display the value.
-- you said you already had player defined and forgot to paste it, so I won't add it here, but dont forget it! while true do script.Parent.Text = player:WaitForChild("CashRecieved").Value wait(0.1) end
Hope this helped! Let me knwo if you have questions or if it didn't work. It should work though!
i don't know if this would work cause i can't test it right now but here it is
toggle = false player:WaitForChild("CashRecieved").Changed:Connect(function() toggle = true if toggle == true then script.Parent.Text = player:WaitForChild("CashRecieved").Value toggle = false end end)