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

How do i make my script repeat itself until a certain string gets printed in the output?

Im new to lua scripting and i need to know how to repeat my script until ("Hello world!") gets printed in the output, this might look a little bit primitive but i tried my best.

game.Workspace.Hello.BrickColor = BrickColor.Random()repeat

until ("Hello World!") wait (5) print ("Hello World!")

2 comments

1

What exactly are you waiting for in output?

0

I think he means doing things like you can do in C# like Console.ReadLine(); . Hovewer, in roblox the only thing you can do in the console is printing, warning and erroring things.

1 answer

Although I'm not 100% sure of the real world use-case of something like this, I'd imagine this could be possible using "LogService"

You could use the MessageOut event like so which fires when a Message is logged in console (works with Warnings, Errors, Info or Outputs like your print)

Game:GetService("LogService").MessageOut:Connect(function(Message, Type) if Message == "Hello World!" then -- do stuff end end)

More Info: https://developer.roblox.com/en-us/api-reference/event/LogService/MessageOut

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