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

Can I make a random part of a string capitalized?

Asked by 10 years ago
    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

Log in to vote
0
Answered by
Azarth 3141 Moderation Voter Community Moderator
10 years ago
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"))
Ad
Log in to vote
-2
Answered by
wazap 100
10 years ago

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)
0
The variable use of 'str' makes me dislike this. Nickoakz 231 — 10y

Answer this question