What would be the best way to restart a script so it starts from the begging? Right now i am just making the script disabled then making it not disabled after i do stuff but it is not working the best.
COMMUNITY QUESTION
What is the best way to restart a script from the begging?
1 answer
If you want to restart a script from the beginning, use return.
Here's an example of return:
local player = "ApinityYT"
script.Parent.MouseButton1Click:connect(function()
if game.Players.LocalPlayer.Name == player then
print("Player found!")
else
return -- This returns to the MouseClick function and waits until it gets clicked again
end
end)
I am not sure if this is correct, if someone would like to correct me, they can do so, i won't be offended because i barely know how to script. (lol..)
1 comment
0
Even if you had an infinite loop in that function, it could still be clicked and ran again and a again. The return is pointless, and doesn't answer the question.
This discussion is preserved as it was. New answers, comments, and votes are closed.

6 comments
A) program it to have a "reset switch" by using functions. B) Clone it
what functions would i use
If you want it to run continually, forever, use while true do.
i know but it requires people so i have it set for when a person leaves it breaks the function and starts a new script that disables the round script then waits for more people to join
Please spell beginning right, as begging has a different meaning.
You should ask another question with your code that you want to restart, because it can depend on the situation.