Tutorial:Renaming

Unlike in other programming languages, every instance, has a Name property. This name property determines the text shown in the explorer next to the icon of the instance, as well as how you access the instance in scripts. In this tutorial, we are going to make a part that continuously changes its name back and forth.

Required Instances
Your Explorer window (if you do not have an Explorer window, go to the View Tab > Explorer. Now, if you do not already have a part in the Workspace, add one. Then, hover over the part in the Explorer window, click the + sign, then add a script. Your Explorer window should now look like this:

Scripting
We are going to use a while loop, which makes all code inside the loop repeat over and over again infinitely. Open up the script. Lets start a while do loop. Notice how we also have a wait statement. It is important to always have a wait statement inside a while loop. This is to prevent the script from executing so fast the server breaks. The number 2 in the brackets specifies that the code should wait 2 seconds each time the code repeats. Next step is to make it change the name. In order to change the name of an instance, we set its Name property to the new name we want. Lets make our name "Thunder" named after the man who wrote this tutorial. Remember: because we are working with Strings, or text, we need to use quotation marks. "Script" refers to the script that you are typing on. "Parent" refers to the hierarchal parent of the script, so in this case, "script.Parent" refers to the part that we are trying to rename. Finally, we change its Name property to "Thunder." This code works and all, but we have this in a while true do loop. Lets make the name change again, to Leira, named off the user who founded the. We will also need another wait(2), so we don't go too fast. We have successfully created a part that continuously changes its name between two strings.