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

how do i make a textlabel switch between phrases?

Asked by 7 years ago

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

Log in to vote
1
Answered by
cabbler 1942 Moderation Voter
7 years ago
Edited 7 years ago

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
0
"Hints" was the text label name that i had NinjaCall456 13 — 7y
0
also, how could i make it random NinjaCall456 13 — 7y
0
First of all you should accept this if it's correct cabbler 1942 — 7y
0
Index the table with math.random() cabbler 1942 — 7y
Ad

Answer this question