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

What is the best way to restart a script from the begging?

Asked by 6 years ago

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.

0
A) program it to have a "reset switch" by using functions. B) Clone it lukeb50 631 — 6y
0
what functions would i use justintubba123 6 — 6y
0
If you want it to run continually, forever, use while true do. awfulszn 394 — 6y
0
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 justintubba123 6 — 6y
View all comments (2 more)
0
Please spell beginning right, as begging has a different meaning. hiimgoodpack 2009 — 6y
0
You should ask another question with your code that you want to restart, because it can depend on the situation. CootKitty 311 — 6y

1 answer

Log in to vote
-1
Answered by
Ap_inity 112
6 years ago
Edited 6 years ago

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..)

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. CootKitty 311 — 6y
Ad

Answer this question