How to know what was printed

I wanted to know if there is a way, you can tell the script what was printed.
Example:

How will I tell the script what was printed? like an if statement?
Example:

how will I tell the script, that cheese was printed

1 Like

When doing the math.random() part, set it to a variable and then print the variable and then you know what was printed.

1 Like
game:GetService("LogService").MessageOut:Connect(function(Message)
	print(Message)
end)
3 Likes

Zamn, didn’t even know that existed.

1 Like

so basically if you print something it will just repeat printing it

i know what ur thinking, it wont gonna repeat inf cuz it prints again Xd

1 Like

Do what @TaxFraudBruh said above

local foods = {"Egg","Cheese","Bread"}
local SelectedFood --This variable contains your 

wait(5)

SelectedFood = foods[math.random(#foods)]) --Sets the variable to your selected food
print(SelectedFood)
1 Like

Everyone’s reply helped me alot! But I’m thinking something like:

local foods = {"Egg", "Cheese", "Bread"}
wait(5)
print(foods[math.random(#foods)])
 if "printed" = Egg then
...

local foods = {"Egg", "Cheese", "Bread"}
wait(5)

local selected = (foods[math.random(#foods)])
print(selected)
 if selected = "Egg" then
...
1 Like
local foods = {"Egg", "Cheese", "Bread"};
local chosenFood = nil;
task.wait(5);
chosenFood = (foods[math.random(#foods)]);
 if chosenFood = "Egg" then
print"isEgg" ;
elseif chosenFood = "Cheese" then
print"isCheese";
else
print"anything";
...
1 Like

Thanks everyone! This is a big help, everyone’s replys are helpful! Have a good day/night!