So,
Say I wanted to do a while true do and put a onClick function inside it, will it work?
✓ ANSWER ACCEPTED
Can you use a function in a while true do loop?
2 answers
✓ Accepted answer
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.
1 comment
0
Thanks
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.
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
don't create the function inside the loop, call it instead.