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

how do i make a textlabel switch between phrases?

i want to have hints on a board in my game, that will randomly switch between them, i've tried to use this scripts

local listOfPhrases = {"Example", "Whatever you want", "Hello, world!", "LOL!"}  
local interval = 3
while wait() do
	for k,v in pairs(listOfPhrases) do
		script.Parent.Name = Hints
		wait(interval)
	end
end

1 answer

✓ Accepted answer

What is "Hints"? You did not define that anywhere. You should use the variables k,v. Or to make things clear, use _,phrase instead. pairs can use any variable. Lastly, for TextLabels to display text you should use the Text property.

local listOfPhrases = {"Example", "Whatever you want", "Hello, world!", "LOL!"}  
local interval = 3
while true do
    for _,phrase in pairs(listOfPhrases) do
        script.Parent.Text = phrase
        wait(interval)
    end
end

4 comments

0

"Hints" was the text label name that i had

0

also, how could i make it random

0

First of all you should accept this if it's correct

0

Index the table with math.random()

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