Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Replacing characters in a string with other characters?

Asked by
gitrog 326 Moderation Voter
6 years ago

So, I have a string in the format FirstName_LastName. I want to replace the "_" with a space. I've been working on this for a while, nothing seems to work properly. I could send you everything I tried, but I don't see a purpose in that. You guys got any ideas?

1 answer

Log in to vote
1
Answered by 6 years ago
Edited 6 years ago

You can easily do this with string.gsub. For example, we can do

local name = 'Player_1'
local function tuis(txt) --turn underscore into space
    local s, _ = string.gsub(txt, '_', ' ')
    return s
end
print(tuis(name))

However, people's usernames cannot have underscores in ROBLOX

Hope this helps!

Ad

Answer this question