Simple Street Light Script! [Beginners Tutorial]

Here is my beginners tutorial for street light scripts!

This script makes a parts light turn on depending on the time, acting like a street light.

   while true do
	if game.Lighting.ClockTime <=6 then --<= means less than or equal to 6
		script.Parent.SurfaceLight.Brightness =16 --Light Brightness
	else
		script.Parent.SurfaceLight.Brightness =0 --Turns Off
	end
	task.wait(0.3)--Prevents Lag
end

Confused? Here I will explain.

Part1

First create a part in the workspace!


Next insert a surface light in side of the part.
image
After that make sure to also insert a script in the part.
Make sure the Surface Light’s brightness is set to 0!

Pro Tip: You can see where the light goes when you click on surface light in the part.
Nice job so far! Now we can go on to part 2! Here comes the scripting! :grinning_face_with_smiling_eyes:

Part2

First we have these two lines.
image

What these two lines basically do is they constantly check of the clock time is less than or equal to 6.
After that line you will soon see this line.
image
This line sets the Surface Lights’s brightness to a specific number. I just put 16 for example. If you set it to 0 the Surface Light will not emit any lights.
After that line you will see a image .
If the Clock time you saw earlier is not less the or equal to the set time it will, then it will go on to else instead of just ending the script.
After that else you will see a wild image !
This basically sets the Surface Light’s brightness to 0 which makes it emit no light.
Finally you will see this image .
The wait(0.3) Just adds a delay before re-reading the script. Making this delay set to nothing can start some lag so be aware! Then it ends here!

Notes :spiral_notepad:

This tutorial is ment for beginner scripters so dont worry you can modify all the numbers listed here!

Numbers

Also this is written in a normal script not a local script!
To change the clock time by the way, you can do it by going to lighting>clocktime
Heres a image of it.

Thanks for seeing and using my tutorial!
Sincerely, John

14 Likes