I made rocket that you can ride upwards, but I want to make it where you get to a certain height that it looks like you're in space. (I had a day-night script that used values) The script I used is (This is in a local script in Starter Gui)
if game.Workspace.Rocket.Base.Main.Position.Y <= 1000 then
game.Lighting.TimeOfDay = "24:00:00"
else
game.Lighting.TimeOfDay = game.Lighting.TimeOfDay
end
It didn't change the Time Of Day, so I tried a while loop
while wait() do
if game.Workspace.Rocket.Base.Main.Position.Y <= 1000 then
game.Lighting.TimeOfDay = "24:00:00"
else
game.Lighting.TimeOfDay = game.Lighting.TimeOfDay
end
end
and this time, the time stayed at 12:00, and it was flashing looking like it was trying to switch the time, and once the rocket got over 1000 height, it stopped flashing. Can somebody give me a working script, or tell me something I did wrong with the current script?

5 comments
second one works but it crashes your game
actually it game script timeouts but whatever same thing you'll probably close your roblox out before you notice roblox times out for you
oh yeah, I forgot to say that I put while wait() do, not while true do.
You're not actually doing anything if the Y value is more than 1,000, you're just setting the TimeOfDay to itself. If you want to to become darker, do game.Lighting.TimeOfDay = "22:00:00" or some other hour that is dark.
Oh my gosh sorry, I forgot to put something else in. I deleted the script so I can't copy and paste. I actually did "24:00:00".