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

How would I make this pick a random quote every 3 seconds?

I've tried SO many times to make it pick a random quote every (x) seconds, but it always breaks one part of the script or the other. I cant figure out why it doesn't work.

Heres the script :

local quotes = {
"Life is 10% what happens to you and 90% how you react to it.",
"Act as if what you do makes a difference. It does.",
"With the new day comes new strength and new thoughts.",
"You will never win if you never begin.",
"A somebody was once a nobody who wanted to and did.",
"It does not matter how slowly you go as long as you do not stop.",
"Failure will never overtake me if my determination to succeed is strong enough.",
"Accept the challenges so that you can feel the exhilaration of victory.",
"Be kind whenever possible. It is always possible.",
"There is only one happiness in this life, to love and be loved.",
"Sometimes the heart sees what is invisible to the eye.",
"Being deeply loved by someone gives you strength, while loving someone deeply gives you courage.",
"Happiness is not something you postpone for the future; it is something you design for the present.",
"No act of kindness, no matter how small, is ever wasted.",
"Unless someone like you cares a whole awful lot, nothing is going to get better. It's not.",
"There is no pain so great as the memory of joy in present grief.",
"As we stand together, we stand forever.",
"When something is important enough, you can do it even if the odds are not in your favor."

}


function pickQuote()
	for i,v in pairs(quotes) do
		script.Parent.Text = quotes[math.random(1, #quotes)]
	end	
end

pickQuote()


local goingUp = true

while wait() do
	if goingUp == true then
		script.Parent.Rotation = script.Parent.Rotation + 0.1
		if script.Parent.Rotation >= 7.5 then
			goingUp = false
		end
	end
	if goingUp == false then
		script.Parent.Rotation = script.Parent.Rotation - 0.1
		if script.Parent.Rotation <= -7.5 then
			goingUp = true
		end
	end
end


1 answer

✓ Accepted answer

If you're trying to pick a random quote, don't use in pairs, just use math.random and add a while wait(3) do.

local quotes = {
"Life is 10% what happens to you and 90% how you react to it.",
"Act as if what you do makes a difference. It does.",
"With the new day comes new strength and new thoughts.",
"You will never win if you never begin.",
"A somebody was once a nobody who wanted to and did.",
"It does not matter how slowly you go as long as you do not stop.",
"Failure will never overtake me if my determination to succeed is strong enough.",
"Accept the challenges so that you can feel the exhilaration of victory.",
"Be kind whenever possible. It is always possible.",
"There is only one happiness in this life, to love and be loved.",
"Sometimes the heart sees what is invisible to the eye.",
"Being deeply loved by someone gives you strength, while loving someone deeply gives you courage.",
"Happiness is not something you postpone for the future; it is something you design for the present.",
"No act of kindness, no matter how small, is ever wasted.",
"Unless someone like you cares a whole awful lot, nothing is going to get better. It's not.",
"There is no pain so great as the memory of joy in present grief.",
"As we stand together, we stand forever.",
"When something is important enough, you can do it even if the odds are not in your favor."

}
function pickQuote ()
	local t = quotes[math.random(1,#quotes)] --Pick random quote
	script.Parent.Text = t --Display it
end
while wait(3) do --Every three seconds
	pickQuote()
end

Please accept my answer if this helped!

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