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

Can you use a function in a while true do loop?

Asked by
KenzaXI 166
9 years ago

So, Say I wanted to do a while true do and put a onClick function inside it, will it work?

0
don't create the function inside the loop, call it instead. ImageLabel 1541 — 9y

2 answers

Log in to vote
0
Answered by 9 years ago

Short answer, yes, but creating a function in a loop will just keep re-writing the previous function with the same function. There is no reason to do this. It will just consume resources with no functionality.

0
Thanks KenzaXI 166 — 9y
Ad
Log in to vote
0
Answered by 9 years ago

Depending on what you want to do, While true do repeats a loop until you tell it to stop, and onClick detects when you click an object, or Gui. If you wanted it to cause something to happen, you would do this

script.Parent.MouseButton1Click:connect(function()

    print("Text") -- this will print "Text" every time you click that object or gui

end)

If this didn't answer your question, Hopefully someone else could help, But as far as I know, Putting a OnClick in a while loop isnt possible, But correct me if i'm wrong.

Answer this question