Find wouldn’t work, Hello World is an example and the real string I’m trying to find the position of the letter has multiple 1s and 2s so I need a way to get the specific letter like #1 or #2 of the string.
string.find finds positions, while string.match searches for a match in a string, returning the match. string.match is more intended for use with the string patterns (the Roblox equivalent of Regex)
I’m just gonna give the exact explanation of what I’m trying to do:
I have a DataStore string with “111111111111”
and I wanna change a specific letter/number in the string.
I’m trying to change the 2nd letter in the string so it would turn into 121111111111 keeping all the original values and just changing that “1” into a “2”.
local String = "11111111111111111111111"
local n = 2 -- Position to replace
local ReplaceWith = "2" -- Replace the nth character with this
local Result = string.sub(String, 1, 1) .. ReplaceWith .. string.sub(String, n+1, -1)