Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How may I create an automatic Spotlight/Pointlight?

I know how to use the Spotlight or Pointlight of course. I have a question though of how you would have lights turn off and on without flipping a switch, and it turns on due to the relation of the time. Such as if I was creating a street light for a Town or City game, and it was night they would be on, and if day, off.

5 answers

Enabled property of SpotLights, PointLights, Fire, Smoke, and I believe Sparkles.

Use the TimeOfDay property in game.Lighting and if the time is more than or less than your desired times, create or destroy the pointlight.

--May not work I thought of it right at the top of my head
while true do
if game.Lighting.TimeOfDay == 00:00:00 then --Edit this to the time of the light is on
game.Lighting.PointLight:clone().Parent = game.Workspace.Light
if game.Lighting.TimeOfDay == 00:00:00 then --Edit this to the time of the light is off
game.Workspace.Light.PointLight:Remove()
end
end

This is kind of a mix of the second and third answers.

while true do
	if game.Lighting.TimeOfDay ==12:00:00 then
		game.Workspace.Brick.PointLight.Enabled = true -- change Brick to the brick, and PointLight to Spotlight if its a Spotlight
	elseif game.Lighting.TimeOfDay == 00:00:00 then  -- change Brick to the brick, and PointLight to Spotlight if its a Spotlight
		game.Workspace.Brick.PointLight.Enabled = false
	end
end
		

Place a block right click on the block you placed point your mouse to insert part click the spotlight and you can use propertys to changer distance and brightness

This discussion is preserved as it was. New answers, comments, and votes are closed.