Hey, I wanted to make a simple GUI that displays tips stored inside a table. I don’t understand why this doesn’t work, I’ve probably done something wrong somewhere in the script…
Here is a ss of the script, the script type is a LocalScript stored inside a TextLabel.
Hey there, math.random() is a function used to generate a random number between 2 numbers. You would only need to put in 2 parameters. The first parameter, is the lowest number it would choose. The second number would be the highest number it would choose. For example, if you put in math.random(1, 5), it would choose either 1, 2, 3, 4, or 5.
local advice = {
"Advice1";
"Advice2";
}
local timeDiff = 15
local txt = script.Parent
while task.wait(timeDiff) do
txt.Text = advice[math.random(1,#advice)]
end
Where are you calling the function?
You need to call it if you want it to run
If you want to run it without a function,
this would work -
local advice = {
"Advice1";
"Advice2";
}
local timeDiff = 15
local txt = script.Parent
while task.wait(timeDiff) do
txt.Text = advice[math.random(1,#advice)]
end
local advice = {
"1",
"2",
"3",
"4",
"5"
}
local timeDiff = 15
local txt = script.Parent
local function tip()
while true do
txt.Text = advice[math.random(1,#advice)]
task.wait(timeDiff)
end
end
game.Players.PlayerAdded:Connect(tip)