Idk what went wrong but it doesnt seem to want to work, for some reason.
Here’s my code:
local sentences = {
"bro rlly stop dying",
"is this thing on?",
"michael jackson is dead",
"beeschurger",
"if you die, then stop dying"
}
local sentence = sentences[math.random(#sentences)]
local sentencechosen = sentences[sentence]
if sentencechosen ~= script.Parent.Text then
sentencechosen = script.Parent.Text
end
You don’t need the sentencechosen variable as you have an array, as well as the fact that you never loop it so the value will only update once. I’d recommend something like such:
local running = true
local sentences = {
"bro rlly stop dying",
"is this thing on?",
"michael jackson is dead",
"beeschurger",
"if you die, then stop dying"
}
local textLabel = script.Parent
while running do
task.wait(2)
local randomSentence = sentences[math.random(1, #sentences)]
if randomSentence ~= textLabel.Text then
textLabel.Text = randomSentence -- Set the textLabels text to the rand sentence
end
end
local sentences = {
"bro rlly stop dying",
"is this thing on?",
"michael jackson is dead",
"beeschurger",
"if you die, then stop dying"
}
local sentence = math.random(#sentences)
local sentencechosen = sentences[sentence]
if sentencechosen ~= script.Parent.Text then
sentencechosen = script.Parent.Text
end
Thanks so much!
adding onto that, if there are any future people who visit this post, this is how to make the text generator only generate once:
local running = true
local sentences = {
"bro rlly stop dying",
"is this thing on?",
"michael jackson is dead",
"beeschurger",
"if you die, then stop dying"
}
local textLabel = script.Parent
while running do
task.wait(2)
local randomSentence = sentences[math.random(1, #sentences)]
if randomSentence ~= textLabel.Text then
textLabel.Text = randomSentence -- Set the textLabels text to the rand sentence
running = false
end
end