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

How do I change the sky color only locally?

Asked by 4 years ago
Edited 4 years ago

Hello,

I am making a script so that when the player's torso y position is > 1500, the sky turns to night time. I'm pretty sure the problem is that i'm trying to make it happen to only one player. When I run the game, the sky turns very bright neon white which is not what happens when I manually change the lighting.

Here is my code, written in a LocalScript located in StarterCharacterScripts:

local character = script.Parent

local Atmosphere = game.Lighting.Atmosphere
local Lighting = game.Lighting

while true do
    local pos = character.UpperTorso.Position.Y
    if pos > 1500 then
        Atmosphere.Color = Color3.new(40,40,40)
        Lighting.TimeOfDay = "24:00:00"
    else
        Atmosphere.Color = Color3.new(250,250,250)
        Lighting.TimeOfDay = "15:00:00"
    end
    wait(2)
end

Thank you again!

0
Note; the part that checks the player's Y position is not the problem. DoudGeorges 38 — 4y
0
what's the output raid6n 2196 — 4y
0
nvm raid6n 2196 — 4y
0
Use local scripts Leamir 3138 — 4y
View all comments (2 more)
0
There is no output, it just turns the sky neon. DoudGeorges 38 — 4y
0
I am already using a LocalScript located in StarterCharacterScripts DoudGeorges 38 — 4y

1 answer

Log in to vote
0
Answered by
gskw 1046 Moderation Voter
4 years ago

The code has a common problem with Color3 values: the constructor expects variables between 0 and 1, not 0 and 255. The fix is to divide everything by 255:

local character = script.Parent

local Atmosphere = game.Lighting.Atmosphere
local Lighting = game.Lighting

while true do
    local pos = character.UpperTorso.Position.Y
    if pos > 1500 then
        Atmosphere.Color = Color3.new(40/255,40/255,40/255)
        Lighting.TimeOfDay = "24:00:00"
    else
        Atmosphere.Color = Color3.new(250/255,250/255,250/255)
        Lighting.TimeOfDay = "15:00:00"
    end
    wait(2)
end
0
Thank you!!!!!! DoudGeorges 38 — 4y
Ad

Answer this question