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

This is supposed to pick a random skybox, but it's not working and the output isn't helping?

Asked by 8 years ago
Edited 8 years ago
01skies = {
02"s1",
03"s2",
04"s3"}
05while true do
06    csky = math.random(1, #skies)
07    wait(0.001)
08    if game.Lighting:GetMinutesAfterMidnight() == 0 then
09        if skies[csky] == "s1" then
10            game.Lighting.Sky.SkyboxBk = "rbxassetid://558861298"
11            game.Lighting.Sky.SkyboxDn = "rbxassetid://558860805"
12            game.Lighting.Sky.SkyboxFt = "rbxassetid://558861465"
13            game.Lighting.Sky.SkyboxLf = "rbxassetid://558860596"
14            game.Lighting.Sky.SkyboxRt = "rbxassetid://558861057"
15            game.Lighting.Sky.SkyboxUp = "rbxassetid://558861628"
View all 35 lines...

Edit: I forgot to mention, the script is in game.Lighting.Sky

1 answer

Log in to vote
0
Answered by 8 years ago

Hmm, I think the problem is that it's just missing the point where MinutesAfterMidnight is 0. I'm not 100% sure, but try this:

01--Assuming that this is a Server script (which it hopefully is)
02skies = {
03"s1",
04"s2",
05"s3"}
06game.Lighting.LightingChanged:connect(function()
07      if game.Lighting:GetMinutesAfterMidnight() == 0 then
08            csky = math.random(1, #skies)
09                if skies[csky] == "s1" then
10                    game.Lighting.Sky.SkyboxBk = "rbxassetid://558861298"
11                    game.Lighting.Sky.SkyboxDn = "rbxassetid://558860805"
12                    game.Lighting.Sky.SkyboxFt = "rbxassetid://558861465"
13                    game.Lighting.Sky.SkyboxLf = "rbxassetid://558860596"
14                    game.Lighting.Sky.SkyboxRt = "rbxassetid://558861057"
15                    game.Lighting.Sky.SkyboxUp = "rbxassetid://558861628"
View all 35 lines...

Lighting has an event which fires every time a property of game.Lighting is changed. As I said, I'm not completely sure it will work, as I personally haven't done much work when it comes to lighting, but try it nonetheless. :)

0
also I might wanna add that if you have some sort of day/night script, make sure at some point of time it actually hits 00:00:00 (aka GetMinutesAfterMidnight() returns 0) because if it hits like 00:01 then 00:03 this might not work. Pengdoo 26 — 8y
Ad

Answer this question