Namee = script.Parent.Namee Nameo = script.Parent.Nameo --Characters Here: local characters = {"_", "q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "a", "s", "d", "f", "g", "h", "j", "k", "l", "z", "x", "c", "v", "b", "n", "m", "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", "A", "S", "D", "F", "G", "H", "J", "K", "L", "Z", "X", "C", "V", "B", "N", "M", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0"} --Length Here: local charLength = 1 local cache = {} --/CONFIGURATION-- local Ui = script.Parent.Parent.ScrollingFrame --You Will See Random Generated Word In Output Window --To Start It Disable This Script And Enable while true do wait() local word = "" for i = 1, charLength do local randNum = math.random(1, #characters) word = word .. characters[math.random(1, #characters)] .. characters[math.random(1, #characters)] .. characters[math.random(1, #characters)] .. characters[math.random(1, #characters)] print(word) Nameo.Text = word wait() word = "" end local Players = game:GetService("Players") local cache = {} function GetUserIdFromUsername(name) -- First, check if the cache contains the name if cache[name] then return cache[name] end -- Second, check if the user is already connected to the server local player = Players:FindFirstChild(name) if player then cache[name] = player.UserId return player.UserId end -- If all else fails, send a request local id pcall(function () id = Players:GetUserIdFromNameAsync(name) end) cache[name] = id return id end if (GetUserIdFromUsername(Nameo.Text)) == nil then Namee.Text = ("Not Taken") local addtolist = Instance.new("TextLabel") addtolist.Parent = Ui addtolist.BackgroundTransparency = 1 addtolist.Size = UDim2.new(5, 0, 5, 0) addtolist.Text = Nameo.Text script.Parent.Image = "rbxassetid://891981050" else Namee.Text = (GetUserIdFromUsername(Nameo.Text)) script.Parent.Image = "http://www.roblox.com/Thumbs/Avatar.ashx?x=200&y=200&Format=Png&userid="..(GetUserIdFromUsername(Nameo.Text)) end end
I have tried using strings but it didn't work, and I don't even know if there is a way. Nameo is the value because it comes back like i said in the title, sometimes.
I added this below Nameo.Text = word and above wait()
if Nameo.Text == string.sub(1,1) == "_" then Nameo.Text = "null" end if Nameo.Text string.sub(4,4) == "_" then Nameo.Text = "null" end
It didn't work...
Luckily for you, Lua provides a method for this. You can use string.gsub, the first argument is the string, the second is the thing you want to replace in the string, and the third is is what you want to replace it with.
Example:
local s = "_Hello_"; s = string.gsub(s, "_", "!"); print(s);
The result is --> !Hello!
EDIT: An optional fourth argument also allows you to specify how many times the function is allowed to replace something.
Example:
local s = "_Hello_"; s = string.gsub(s, "_", "!", 1); print(s);
The result is --> !Hello_