Gui Text button to change Time/Lighting

Hello, I’m trying to make a text button that when you clicked it, it changes the time/lighting/ambience/tintcolor/brightness to the numbers in the code. But, it doesn’t seem to work, if anyone can help me figure out why it wouldn’t work that would be a great help.

This is a GUI with a text button that changes setting of the day like the time and lighting.

local lightingsunset = game.Lighting

local lightingsuncorrection = game.Lighting.ColorCorrection

local clocksuntime = game.Lighting.ClockTime

--Sunset

script.Parent.MouseButton1Click:Connect(function()

game.Lighting.ClockTime = clocksuntime

game.Lighting.ColorCorrection = lightingsuncorrection

game.Lighting.Ambient = lightingsunset

-- Lighting ambient setting

lightingsunset.Ambient.R = 220

lightingsunset.Ambient.G = 121

lightingsunset.Ambient.B = 21

-- Lighting fog setting

lightingsunset.FogColor.R = 226

lightingsunset.FogColor.G = 175

lightingsunset.FogColor.B = 112

-- Lighting brightness

lightingsunset.Brightness = 60

-- Color correction setting

lightingsuncorrection.Contrast(-0.1)

lightingsuncorrection.TintColor(255, 131, 69)

lightingsuncorrection.Saturation(-0.1)

lightingsuncorrection.Brightness(0.1)

-- Clock time setting

clocksuntime = 17.6

end)

Whats the error? It may be that you not using waitforchild() for allow time for instances to load but I’d like to see what your errors are first.

colorcorrrect

local LightingService = game:GetService("Lighting")
local ColorCorrection = LightingService:WaitForChild("ColorCorrection")

script.Parent.MouseButton1Click:Connect(function()
	LightingService.Ambient = Color3.fromRGB(220, 121, 21)
	LightingService.FogColor = Color3.fromRGB(226, 175, 112)
	LightingService.Brightness = 60
	LightingService.ClockTime = 17.6
end)
3 Likes
local colorcorrection = Instance.new('ColorCorrectionEffect',game.Lighting)
local lightingsunset = game.Lighting
local lightingsuncorrection = colorcorrection
local clocksuntime = game.Lighting.ClockTime

script.Parent.MouseButton1Click:Connect(function()
lightingsunset.Ambient = Color3.fromRGB(1,1,1) -- this is the rgb color
-- Lighting fog setting
lightingsunset.FogColor = Color3.fromRGB(1,1,1) -- this is the rgb color
-- Lighting brightness
lightingsunset.Brightness = 60
-- Color correction setting
lightingsuncorrection.Contrast = -0.1
lightingsuncorrection.TintColor = Color3.fromRGB(255, 131, 69)
lightingsuncorrection.Saturation = -0.1
lightingsuncorrection.Brightness = 0.1
-- Clock time setting
clocksuntime = 17.6
end)

you can not use or assign the values without adding = in between. and for color you have to add what type of color u r using e.g rgb, hsv etc.

i have fixed your script for you. so you can use it and hopefully understand it better.

1 Like

To make this code more efficient I would use it in a function all the settings for the Lighting service and just connect it on the textbutton activated function like this.

--// Services \\--
local Lighting = game:GetService("Lighting")

--// Variables \\--
local Button = script.Parent:WaitForChild("Button")

--// Functions \\--
local function SetLighting()
    -- Add all the settings needed here
end)

--// Events \\--
Button.MouseButton1Clicked:Connect(function()
    SetLighting()
end)
1 Like

thanks so much this worked :+1: :+1: :+1: