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

Randomized Strings That Constantly Add On To A TextBox?

I want to create a simple text addition generator. I don't want the Text input to clear and restart with a fresh item. I just want it to constantly add more items in a random way. I don't want print statements like shown in this example. It will randomly pick between either a Phoenym or Alphabet.

Bonus if you want to help with something extra; I would like it to be able to pick Phoenyms in a row. Obviously not always as the case though. However not be able to generate Alphabet in a row. While always allowing the ability to mix both. That's a major part of this project that I am making. Therefore it would be great if someone would help. If not then it's alright. I just won't ever be able to complete the project then on my own. I honestly don't know any programming languages or how to script Lua. Which is why it lacks the majority of code to make this work right.

The intended usage of the script is to generate possibly words at random. Without having a data bank for already having them. This would make it unique and strange if it ever landed on something. That is pretty much what I am going for with this idea.

local table Phoenym = {"aeh","ahh","air",
"al","an","awe","buh","ch","cuh","duh",
"ear","eh","er","ff","guh","huh","ii",
"iihh","ill","in","ing","ink","juh","luh",
"mm","nuh","ol","om","onh","oo","or","qwa",
"ruh","ss","st","th","tt","uh","ul","um",
"un","vv"},"wuh","ya","zz"}

local table Alphabet = {"a","b","c",
"d","e","f","g","h","i","j","k","l",
"m","n","o","p","q","r","s","t","u",
"v","w","x","y","z"}

 -- Items table.
	while true do
	local value1 = math.random(1,#Phoenym)
	local value2 = math.random(1,#Alphabet) -- Get random number with 1 to length of table.
	local picked_value1 = Phoenym[value1] -- Pick value from table
	local picked_value2 = Alphabet[value2]
	
	print(tostring(picked_value1))
	print(tostring(picked_value2)) -- Print picked value
	wait(1)
	end

2 comments

0

Just do: TextBox.Text = TextBox.Text .. picked_value1 .. picked_value 2

0

https://idownvotedbecau.se/toomuchinfo/ (or atleast i wanted to)

1 answer

✓ Accepted answer

To add text to a string, you can use local string = string .. addition where string is the variable for the string you are adding to and addition is the letter/phoenym selected.

Quick tip, for the random letter, you can save space by instead using string.char() for generating a random lowercase letter. Here's the code I ended up using:

local s = ""
local table p = {
	"aeh", "ahh", "air", "..." --just use your phoenym table!
}
while wait(1) do
	s = s .. p[math.random(1, #p)] .. string.char(math.random(97, 122))
	print(s)
end

I didn't know how you wanted to add things, so I'll specify how the "s = s .." line works. "p[math.random(1#p)]" is the portion that adds from the phoenym table. "string.char(math.random(97, 122)" is adding a random letter from the alphabet. if you wanted to, say, randomly pick from one, you can use math.random to essentially flip a coin in the script and use if then to read if, say you use math.random(1, 2), if the output is 1 or 2 to decide if you want to add a phoenym or a letter. Here's how that would work:

local s = ""
local table p = {
	"aeh", "ahh", "air", "..." --just use your phoenym table!
}
while wait(1) do
	if math.random(1, 2) == 1 then
		s = s .. string.char(math.random(97, 122))
	else
		s = s .. p[math.random(1, #p)] 
	end
	print(s)
end

Hope this helped! Be sure to accept this as an answer if it did :)

2 comments

0

Best helpful person I have had on here.so far. It's actually adding things together on to the string which I like. Anyway to seperate the individual phoenyms to make them more readable? Just wondering. Also would you know how to implement the alphabet into this? Like I said above in the bonus portion of the description. If you want to extra help me with this please read it to understand completely

0

I will already accept this answer as helpful. I just hope you know how to help with the project portion too.

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