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

Why won't this script work??

Hi, I'm just learning Scripting and i did this script as example but it doesn't work:

while true do
wait(1)
game.Workspace.Lighting.TimeOfDay = "00:00:00"
wait(1)
game.Workspace.Lighting.TimeOfDay = "12:00:00"
wait(1)
game.Workspace.Lighting.TimeOfDay = "01:00:00"
end

I don't get why it doesn't work because it got no red checkmarks, nor blue ones, Please help?

Oh i almost forgot to say that in the Output it prints this: 17:47:51.347 - Stack End 17:47:52.364 - Lighting is not a valid member of Workspace 17:47:52.364 - Script 'Workspace.Script1', Line 3 17:47:52.365 - Stack End

1 comment

0

It is game.Lighting, not game.Workspace.

1 answer

✓ Accepted answer

Your problem is that you're trying to access Lighting as a descendant of Workspace. The Lighting property is actually a descendant of the game itself, therefore need to access it using game.Lighting.


If done correctly, your code should look like this:

while true do
	wait(1)
	game.Lighting.TimeOfDay = "00:00:00"
	wait(1)
	game.Lighting.TimeOfDay = "12:00:00"
	wait(1)
	game.Lighting.TimeOfDay = "01:00:00"
end

Ok, well now this should work. If it doesn't, or you have any further problems/questions, please leave a comment below, and I'll see what I can do. Hope I helped :P

####-Dyler3

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