I have an integer value, and I need to convert the numbers it displays into a string to show it on a GUI. Any idea how?
[EDIT] My script
1 | while true do |
2 | script.Parent.Text = game.Workspace.Shields.Value + "%" |
3 | wait( 0.1 ) |
4 | end |
If I'm correct, you'd use the tostring
method to convert a number or integer to a string.
1 | while true do |
2 | script.Parent.Text = tostring (game.Workspace.Shields.Value .. "%" ) -- use tostring method to convert integer to string |
3 | wait( 0.1 ) |
4 | end |
By the way, to combine 2 strings/integers, use ..
instead of +
, because +
makes the script try to add 2 values. You can't add a string + a number.
You can do this one of two ways.
Calling the function tostring
on the number
x = tostring(number) print(x)
Concatenation
x = 5 print("High"..x) --> "High5"