Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
2

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

Asked by 14 days ago
Edited 14 days ago

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)

0
Is this in a `LocalScript` or a `Script` TTChaos 200 — 14d
0
Its inside a script KochbananemitGuave 166 — 14d
0
Brightness modifications should be inside a `LocalScript` TTChaos 200 — 14d
0
Ok thanks KochbananemitGuave 166 — 14d
View all comments (4 more)
0
Do you want to make a day-night cycle? TTChaos 200 — 14d
0
Yes, but without the Clocktime KochbananemitGuave 166 — 14d
0
I just want to wait some seconds, then make it dark, then bright,etc. KochbananemitGuave 166 — 14d
0
Also, when I put the code in a localscript, it said Unable to cast Value to Object. KochbananemitGuave 166 — 14d

3 answers

Log in to vote
2
Answered by
imKirda 731 Moderation Voter
14 days ago
Edited 14 days ago

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.

Ad
Log in to vote
1
Answered by
TTChaos 200 Moderation Voter
14 days ago
Edited 14 days ago

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

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. TTChaos 200 — 14d
0
?? KochbananemitGuave 166 — 14d
0
You didn't have too? If you like to help me, then do it, and if you don't, then don't. KochbananemitGuave 166 — 14d
1
Sorry. There was another person saying that my thing didn't work when it actually does. He then deleted the comment immediately after. TTChaos 200 — 14d
Log in to vote
0
Answered by 14 days ago

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

Answer this question