How I would create an infinite function?

In trying to make a script where when you touch an orb, that orb is destroyed, and another will appear, and repeat that. The problem is that I thought I would be able to make it, but I wasn’t. So basically, I already tried to cook my brain to get information to solve this, but nothing helped. Basically, if you need a bit of my code, I can give it. Thanks for reading :+1:

can’t you just use a while loop to repeatedly call the function?


While wait(5) do

Hello42bacon’s method would disable the script below that “while wait(5)” because it would repeat that “callFunction()” forever.

If you want to have some script below that “while”, you could instead used .Changed to see when the orb is destroyed, and then call the function. Instead of using :Destroy() to get rid of the orb, you could change its CFrame, or set every part inside of it with a transparency of 1.


	[YourOrbHere].Transparency = 1
	[YourOrbHere].CFrame =
	[YourOrbHere].Transparency = 0
	[YourOrbHere].CFrame = location)

This example would probably also just error because of re-entrancy issues due to the fact setting any properties inside of Changed call Changed again. Did you mean Touched instead?


No where in there does the .Changed call itself again. You could have a .Touched that could change something, which would then activate the .Changed, or you could also just do straight .Touched.

1 Like

Setting the orb’s transparency will trigger the Changed event, which will set the orb’s transparency, triggering a Changed event, which will set the orb’s transparency… This will absolutely call itself again.


My bad, I just had brain fart. You could replace .Changed with .Touched and it would work.


you could use clone() for making an orb just like it, then use destroy() to get rid of the orb. using clone() copies the script(and anything else inside it thats a child to the orb) inside the orb to its cloned version.
note: the property Archivable in the orbs properties needs to be checked in order to use clone()

1 Like