Random Text Script

Hello so i attempted to make a random text script

local expurgationText = {"YOU AREN'T HANK", "WHERE IS HANK", "WHY CAN'T I KILL?????", "MIDGET", "SYSTEM UNRESPONSIVE", "THIS ISN'T RIGHT", "WHERE AM I", "WHO ARE YOU", "HANK???"}
local text = script.Parent.Texts

function changeText()
	local randomMessgaes = expurgationText[math.random(#expurgationText)]
	
	while wait()  do
		text.Text = expurgationText
	end
end

while wait() do
	script.Parent.Texts.Rotation = math.random(-5,3)
end

this is what im trying to go for

math.random requires 2 inputs

local randomMessgaes - expurgationText[math.random(1,#expurgationText)]

Input 1 is the lowest value, Input 2 is the max.

Also, “text.Text = randomMessgaes”, Because that’s the random text that’s been chosen.

in short;

local expurgationText = {"YOU AREN'T HANK", "WHERE IS HANK", "WHY CAN'T I KILL?????", "MIDGET", "SYSTEM UNRESPONSIVE", "THIS ISN'T RIGHT", "WHERE AM I", "WHO ARE YOU", "HANK???"}
local text = script.Parent.Texts

function changeText()
	local randomMessgaes = expurgationText[math.random(1, #expurgationText)]
	
	while wait()  do
		text.Text = randomMessgaes
	end
end

while wait() do
	script.Parent.Texts.Rotation = math.random(-5,3)
end


nothing happens, im going to check my output

Are you running changeText() multiple times, Cause it looks like you’re running it once.

EDIT: I see the issue, Basically you’re changing the text in a loop, but not choosing a new message in the loop.

function changeText()
	while wait()  do
        local randomMessgaes = expurgationText[math.random(1, #expurgationText)]
		text.Text = randomMessgaes
	end
end
3 Likes

there we go, thanks dude. Have a good day

1 Like

one more question, I’m trying to make it so the text gets changed each second BUT when i put it into the original loop for the text rotation it makes it go really fast but i don’t want that to happen so i made a second loop which will change the text each second and still will keep the fast rotation going

while wait() do
	script.Parent.Texts.Rotation = math.random(-5,3)
end

while true do
	wait(1)
	changeText()
end

im really sleepy so dont mind my bad grammar and scripting

Sorry, I don’t quite understand the question.
You want the changetext() and rotation to be in the same loop??

No, i want them to have separate loops.

First Loop

  • Lets Text Rotate Fast

Second Loop

  • Changes Text Each Second

Ah, The reason why your second loop isn’t running, Is because your first loop is yielding.
To fix this, Simply do this:

coroutine.wrap(function()
   while wait() do
	  script.Parent.Texts.Rotation = math.random(-5,3)
   end
end)()

while true do
	wait(1)
	changeText()
end

THANK YOU, you just saved my life. Hope you have an amazing day

1 Like