Okay, so I have a LocalScript that gets cloned into the Player's PlayerGui when they click a button. As soon as it is copied into the PlayerGui, I want it to immediatly start running the first function in it. But I don't know how to get it to do that? If I just call the function first thing, it doesn't work because the function is underneath in the script.
Does anyone know how I would get around this problem? Is there some event that can detect when a LocalScript is placed in a Player? Or any other Event that could help me in this situation?
Thanks in advance.

4 comments
You don't have to put it in a function. Just disable the script until it gets teleported into the player.
But I need it to be a function because I have that same first function run again later in the script.
You can check to see if something is added to the players Character with the ChildAdded event
But the LocalScript won't start running until it is inside the Character. So by the time it is cloned in there and starts running, it (the Child) will already be added.