Answered by
5 years ago Edited 5 years ago
The answer is, no. There is no function that can restart a script. But! There are certain ways you may restart your scripts with.
1) Disable and enabling the script again.
Disabling a script an re-enabling it is a very common way! Each script in Roblox has a property called "Disabled". Whenever the value is true the script will stop running. This is a very useful way and I can tell you I used it multiplie times. I will give you an example!
2 | if hit.Parent:FindFirstChild( "Humanoid" ) then |
3 | game.ServerScriptService.Rain.Disabled = true |
5 | game.ServerScriptService.Rain.Disabled = false |
9 | script.Parent.Touched:Connect(onTouch) |
This script disables a script that contains a rain that gets stronger and stronger every 3 secounds. Whenever you touch the brick, it will instantly disable the script for 3 secounds, and then enable it. Which will mean the rain will stop and suddenly start again from the less stronger wind.
2) Cloning/Disabling old script (NOT 100% SURE ITS WORKING).
I apologize but when typing this answer I do not have a lot of time to answer before I need to go. So I would not be able to give you an example. Basically. When you clone a script it clones the source of it as well (NOT SURE). By that, you can disable the old script, and make the new one enabled, this will restart the script from the top to the bottom.
I hope this was helpful. XDvvvDX!