Probably going to get flagged for not constructive but hopefully, I can get an answer.
I want to figure out how to add commas, this script is in a local script through a TextLabel, I'm wanting it to add a comma connected to an IntValue. This is my script which will probably get flagged for it but I have no idea on how to go about doing this.
local plr = game:GetService("Players") local player = plr.LocalPlayer while wait(1) do script.Parent.Text = "$".. player.RebirthNeeds.Value end
Heres one way:
function addComas(str) return #str % 3 == 0 and str:reverse():gsub("(%d%d%d)", "%1,"):reverse():sub(2) or str:reverse():gsub("(%d%d%d)", "%1,"):reverse() end --example: local IntValue = workspace.IntValue print(addComas(tostring(IntValue.Value)) --the function will only work with a string. You can convert numbers to string using tostring(value) --You can use the 'Changed' event instead of a loop: player.RebirthNeeds.Changed:Connect(function() script.Parent.Text = "$" .. addComas(tostring(player.RebirthNeeds.Value)) end)