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

How do I change the sky color only locally?

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!

6 comments

0

Note; the part that checks the player's Y position is not the problem.

0

what's the output

0

nvm

0

Use local scripts

0

There is no output, it just turns the sky neon.

0

I am already using a LocalScript located in StarterCharacterScripts

1 answer

✓ Accepted answer

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

1 comment

0

Thank you!!!!!!

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