Monument Posted April 23, 2021 Share Posted April 23, 2021 (edited) hello guys, i want to make Sporadic letters ( A,B,C ) what ever setElementData(localPlayer,"Text","Text") P1,P2,P3,P4,P5 = getElementData(localPlayer,"Text") -- that mean P1 = T , P2 = e , P3 = x Edited April 23, 2021 by Monument Link to comment
DiSaMe Posted April 23, 2021 Share Posted April 23, 2021 You need string.sub function, it returns a substring of the string. Using the same position for start and end, you get single characters. local value = "Text" local P1, P2, P3, P4 = string.sub(value, 1, 1), string.sub(value, 2, 2), string.sub(value, 3, 3), string.sub(value, 4, 4) Because the value is a string, you can call string functions on it as methods, using OOP syntax. This one is a little shorter and does the same thing as above: local value = "Text" local P1, P2, P3, P4 = value:sub(1, 1) value:sub(2, 2), value:sub(3, 3), value:sub(4, 4) Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now