Is there a way to restart a script?

ok so, i was wondering if there is a way to say to the script to jump at the begin, is there a built in function?

7 Likes

just put the script in a function and do this:

function yourFunction()
    --Your Code
    yourFunction()
end
5 Likes

can u fire a function is a function?

Yes you can. Not 100% good practice but it works

1 Like

Disable the script and then enable it again.

1 Like

that is even worse practice, mine is in one script, that is with multiple

1 Like

Or -while true do-
if you want it to be restarting over and over.

1 Like

You can enable and disable a script from the script, it is able to disable itself, and reenable itself. The script will still run even if it is disabled.

You can do something like:

script.Disabled = true
wait(1)
script.Disabled = false

that could would function correctly.

11 Likes

You can use loops to if you want. But since you already have a solution that is fine. Let me know if you would like an explanation on loops.

3 Likes

Can you still explain how to use loops cause im making a timer for my oven but my loadbar only works once

Check out this article about Loops. It explains it pretty well!

Try disabling it then enabling it again.