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

How do I Reboot a script once it has stopped?

Asked by 6 years ago

Say you were using a random generator to generate a number and you have a loop going until this number is greater than 5 and then it will stop the script. I want to know how to restart the script so that it starts over again and then generates a random number still. Preferably how to restart with a mouse click.

1 answer

Log in to vote
0
Answered by 6 years ago

There are many answers to that... Most likely thing you would use are functions/events

local CD = script.Parent -- Clickdetector
t = 0

CD.MouseClick:connect(function(click)
    repeat
        number = math.random(1,10)
    until  number > 5
end)

You can also do this (used less) with cloning. (Storing the script in serverstorage and clone it when you need it) This is better for larger scripts.

Ad

Answer this question