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

[Unsolved] Why is the world not becoming Darker/Brighter?

I tried this:

BecomeBright = {}
BecomeBright.Brightness = 0.2

BecomeDark ={}
BecomeDark.Brightness = -0.7

DayTween = Ts:Create(lighting.ColorCorrection.Brightness,TweenInfo.new(1,Enum.EasingStyle.Sine, Enum.EasingDirection.Out,0,false,0),BecomeBright)

NightTween = Ts:Create(lighting.ColorCorrection.Brightness,TweenInfo.new(1,Enum.EasingStyle.Sine,
Enum.EasingDirection.Out,0,false,0),BecomeDark)


while true do
	wait(2)
	DayTween:Play()
	wait(2)
	NightTween:Play()
	wait(2)
end

But the brightness doesnt change... -_- (help)

8 comments

0

Is this in a LocalScript or a Script

0

Its inside a script

0

Brightness modifications should be inside a LocalScript

0

Ok thanks

0

Do you want to make a day-night cycle?

0

Yes, but without the Clocktime

0

I just want to wait some seconds, then make it dark, then bright,etc.

0

Also, when I put the code in a localscript, it said Unable to cast Value to Object.

3 answers

✓ Accepted answer

I would do it like this, similar to your code:

local ts = game:GetService("TweenService")
local lighting = game:GetService("Lighting")
local cc = lighting:WaitForChild("ColorCorrection")

local day_brightness = 0.2
local night_brightness = -0.7

local day_night_ti = TweenInfo.new(
	1,
	Enum.EasingStyle.Sine,
	Enum.EasingDirection.In,
	0,
	false,
	0
)

local function become_bright()
	local tween = ts:Create(cc, day_night_ti, {Brightness = day_brightness})
	tween:Play()
end

local function become_dark()
	local tween = ts:Create(cc, day_night_ti, {Brightness = night_brightness})
	tween:Play()
end

while true
do
	become_dark()
	wait(2)
	become_bright()
	wait(2)
end

I hope you understand it, i tried not to change much.

If you want to make a Day-Night cycle, try this code:

-- Set variables
local minutesAfterMidnight = 12 * 60 -- It's currently 12:00 PM
local loopNumber = 0 -- Set the current loop Number

local function round(x)
	return x + 0.5 - (x + 0.5) % 1
end

while true do -- Start a infinite repeat loop
	minutesAfterMidnight = minutesAfterMidnight + (1 / 6) 
	-- Add ten seconds to the in-game time every millisecond
	
	game.Lighting:SetMinutesAfterMidnight(minutesAfterMidnight) -- Set the timer
	wait(.01) -- Wait a millisecond	
	loopNumber = loopNumber + 1 -- Add a cycle
end -- End the cycle

Edit: This uses the clock, however, the clock makes the sun and moon and sky move around.

Your code should be this (made neater)

local Lighting = game:GetService("Lighting")
local TweenService = game:GetService("TweenService")
local ColorCorrection = Lighting.ColorCorrection
local Bright = {Brightness = 0.2}
local Dark = {Brightness = -0.7}
local BrightnessInfo = TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.Out,  0, false, 2)

DayTween = TweenService:Create(Lighting, BrightnessInfo, Bright)
NightTween = TweenService:Create(Lighting, BrightnessInfo, Dark)

while true do
    DayTween:Play()
    NightTween:Play()
end

4 comments

0

I tried it so please don't waste my time reading your comment for 10 minutes straight I have better things to do with my life.

0

??

0

You didn't have too? If you like to help me, then do it, and if you don't, then don't.

1

Sorry. There was another person saying that my thing didn't work when it actually does. He then deleted the comment immediately after.

Try this

BecomeBright = {}
BecomeBright.Brightness = 0.2

BecomeDark ={}
BecomeDark.Brightness = -0.7

DayTween = Ts:Create(lighting.ColorCorrection.Brightness,TweenInfo.new(1,Enum.EasingStyle.Sine, Enum.EasingDirection.Out,0,false,0),BecomeBright.Brightness)--[[changed BecomeBright to BecomeBright.Brightness]]

NightTween = Ts:Create(lighting.ColorCorrection.Brightness,TweenInfo.new(1,Enum.EasingStyle.Sine,
Enum.EasingDirection.Out,0,false,0),BecomeDark.Brightness)-- same change as above


while true do
    wait(2)
    DayTween:Play()
    wait(2)
    NightTween:Play()
    wait(2)
end

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