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

My lights won't turn off at night?

So basicly, I've been working on my prison game, but the lights for the yard won't turn off at the night. The material changes great. Here's the script:

while true do wait(5)


for i, v in pairs(game.Workspace:GetChildren()) do
	if v.Name == "NeonPart" then
		v.Material = "Neon"
	elseif v.Name == "LightPart" then
		v.SpotLight.Enabled = true
	end
end

game.Lighting.TimeOfDay = "00:00:00"
game.Lighting.GlobalShadows = false
wait(5)

for i, v in pairs(game.Workspace:GetChildren()) do
	if v.Name == "NeonPart" then
		v.Material = "SmoothPlastic"
	elseif v.Name == "LightPart" then
		v.SpotLight.Enabled = false
	end
end

game.Lighting.TimeOfDay = "12:00:00"
game.Lighting.GlobalShadows = true
end

Please note when giving answer, I'm still a beginner with scripting

2 comments

0

I'm in a hurry right now, so i'll make a quick question for you to answer: Were there any errors in the output window? It'd help if there were some errors so you can identify the problem more easily. (If you don't know where the output window is, click 'VIEW' on the tabs at the top, then click the output bar button)

0

I'd suggest looking into GetMinutesAfterMidnight in the wiki. I am sorry, I am in a hurry now, but I think that will put you on the right track to solving your problem.

1 answer

Uh, I just woke up but it doesn't seen like you even checked if the it was night or day..

if game.Lightning.TimeOfDay == "00:00:00" then
--On.. etc
end

2 comments

0

I don't think he is doing that, he seems to be changing the time himself, then changing the properties.

0

That says lightning lol

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