In Explorer, click on ServerScriptService. Scripts will run inside this service, and will not replicate to game clients, allowing for secure storage of your scripts. In other words, they will run on Roblox's servers.
Add a Script
When you click on the + button, select Script.
A Script is a type of Lua code container that will run its contents on the server. By default, Scripts have print("Hello, world") as their contents.
Save to File
Click on File and Save to File
Output Window
In View, click on Output
Play Button
In Script Menu, click on Play
If all goes well, you should see Hello World in the Output window at the bottom of your screen.
Stop
Make sure you click on Stop (on the right) before editing your game further.
2. Insert a Part
Pick a Part, any part.
Rename the Part to MyPart or another intuitive name.
Add a Script to MyPart.
Let's change the properties of our Part via Lua.
Create a local variable named mypart to store Workspace MyPart
1
-- Create a variable to store the part
2
local mypart = game.Workspace.MyPart
Copied!
Change the brick to a random color.
1
-- Changes the color of loopingPart every few seconds
2
-- Create a variable to store the part
3
local mypart = game.Workspace.MyPart
4
mypart.BrickColor = BrickColor.Random()
Copied!
For your reference, here are a list of different possible colors:
BrickColor Codes
3. Wait Function
To make the script wait before running the next line of code, use a wait() function.
1
wait(3)-- waits 3 seconds
Copied!
Change your part to random colors.
1
-- Changes the color of loopingPart every few seconds
2
-- Create a variable to store the part
3
local mypart = game.Workspace.MyPart
4
whiletruedo
5
--
6
wait(3)
7
end
Copied!
4. Spawn Location
Add a Spawn Location or multiple Spawn Locations to your game. It's the icon under Effects.
5. Touched
Use the Touched Event to change the color of your Part when a Humanoid comes into contact with it.
BasePart.Touched
6. Surface Guis
Using surface GUIs, you can add interfaces directly into your game world to create shop signs, keypad panels for locked doors, or even touch screens.