First create a new Actor using Instance.new()
and make sure to parent it to the parent of the script
local actor = Instance.new("Actor", script.Parent)
Following, add a task.wait() in between, and something that you can use to tell if the loop is working. In this case, we’ll just use the good old print.
print("hello world")
task.wait()
Finally, the last step is to change the parent of the script to the actor.
script.Parent = actor
Your code should look like this:
local actor = Instance.new("Actor", script.Parent)
print("hello world")
task.wait()
script.Parent = actor
If you’ve done everything right, your output should behave like this:
This also works in live-games, I have tested it.
You should be able to see your memory increasing every 1~5 seconds by 1mb, sometimes 3-5mb.