Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Can I make a random part of a string capitalized?

	ssstr = umg dat pie do"

for i = 1,#ssstr do
	
   game.Players.Bob.PlayerGui.BALD.Text = (string.sub(string.upper(ssstr[math.random(1,#ssstr)]),1,i)
    wait(.01)
end

I want to make it a random letter capital. Also, all game.Players.Bob.PlayerGui.Bald.Text is correct. I just can't figure out how to make a random letter uppercase.

2 answers

local function split(_string)
	local letters = {}
	for i in string.gmatch(_string, "%a") do 
		table.insert(letters, i)
	end
	local letter = letters[math.random(#letters)]
	return string.gsub(_string, letter,  letter:upper(),1)
end

print(split("if you like pina coladas"))

Easy lol

local str = "wow you're really a  noob"

local index = math.random(#string)

string = str:sub(1, index-1)..str:sub(index, index):upper()..str:sub(index+1)

1 comment

0

The variable use of 'str' makes me dislike this.

This discussion is preserved as it was. New answers, comments, and votes are closed.