Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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.

6 comments

0

A) program it to have a "reset switch" by using functions. B) Clone it

0

what functions would i use

0

If you want it to run continually, forever, use while true do.

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

0

Please spell beginning right, as begging has a different meaning.

0

You should ask another question with your code that you want to restart, because it can depend on the situation.

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.