I want to add a digit to a textbox/stringvalue. I mean I don't want to do math like 1+1=2 but just get the current number like 1 and add to it 1 so the script would change text value to 11 (Yes, I didn't know the concatenation)
01 | script.Parent.MouseButton 1 Click:connect( function (buy) |
02 | local view = script.Parent.Parent.Parent.SUMA.P 12. Text |
03 |
04 | if view = = 0 then |
05 | wait( 1 ) -- just nothing |
06 | elseif view > 0 then |
07 | -- there i need that function so to add a digit in text |
08 |
09 | wait( 1 ) |
10 | end |
11 |
12 | end ) |
Well, I'm new to Lua programming.
What you're trying to do is called concatenation. The concatenation operator in Lua is ..
here's an example of its use:
1 | local str = "Concat" |
2 |
3 | print (str .. "enation" ) -- Prints "Concatenation" |
If my answer solved your problem please don't forget to upvote and accept it!
You could do x * 10 + y, this would effectively add a digit to your value.
1 | function addDigit(x,y) |
2 | return x * 10 + y |
3 | end |
4 | print (addDigit( 5 , 7 )) |
5 |
6 | print (addDigit( 234 , 8 )) |
Output:
57
2348