Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

(SOLVED!) How do you make an Outer Space script once you get to a certain height?

Asked by 5 years ago
Edited 5 years ago

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)

1if game.Workspace.Rocket.Base.Main.Position.Y <= 1000 then
2game.Lighting.TimeOfDay = "24:00:00"
3else
4game.Lighting.TimeOfDay = game.Lighting.TimeOfDay
5end

It didn't change the Time Of Day, so I tried a while loop

1while wait() do
2    if game.Workspace.Rocket.Base.Main.Position.Y <= 1000 then
3    game.Lighting.TimeOfDay = "24:00:00"
4    else
5    game.Lighting.TimeOfDay = game.Lighting.TimeOfDay
6    end
7end

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?

0
second one works but it crashes your game Fifkee 2017 — 5y
0
actually it game script timeouts but whatever same thing you'll probably close your roblox out before you notice roblox times out for you Fifkee 2017 — 5y
0
oh yeah, I forgot to say that I put while wait() do, not while true do. marioman1932 48 — 5y
0
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. Unhumanly 152 — 5y
0
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". marioman1932 48 — 5y

1 answer

Log in to vote
0
Answered by
Unhumanly 152
5 years ago

I hope I'm getting this right.

You want to (locally) change the TimeOfDay from 12:00:00 to 24:00:00 in Lighting to make it appear that the Player is in space when they ride the rocket.

1while wait() do
2    if game.Workspace.Rocket.Base.Main.Position.Y <= 1000 then
3        game.Lighting.TimeOfDay = "12:00:00"
4    else
5        game.Lighting.TimeOfDay = "24:00:00"
6    end
7end

Now, this should work just fine, but since I don't know the whole context of this game, I'm going to assume the Player can exit the rocket at any time and fall all the way back down to the ground.

If they're on the ground and the Rocket reaches an altitude of 1,000 studs, the sky will still darken for them, because the LocalScript is looking at the height of the Rocket, not the Player.

If I were you, I'd consider checking the height of the Character's HumanoidRootPart, and not the Rocket.

01local Player = game.Players.LocalPlayer
02local Character = (Player.Character or Player.CharacterAdded:Wait())
03local HumanoidRootPart = Character:WaitForChild('HumanoidRootPart')
04 
05while wait() do
06    if HumanoidRootPart.Position.Y <= 1000 then
07        game.Lighting.TimeOfDay = "12:00:00"
08    else
09        game.Lighting.TimeOfDay = "24:00:00"
10    end
11end

I hope I helped.

0
I just found out the problem. it was supposed to be >=, not <=. Thanks! marioman1932 48 — 5y
0
If you flip the operator <= in my code, then you'll have to flip 12:00:00 and 24:00:00, otherwise it will be 24:00:00 on the ground and 12:00:00 in space. You can just leave my code as it is, and it works just fine. Unhumanly 152 — 5y
Ad

Answer this question