Script only works on Server Side

I’m trying to change the lighting when the Bool Value “DayTime” changes. The script only works on the server side but not on the client side.


lightning = game:GetService("Lighting")

function midnightTime()
	lightning.Ambient = Color3.fromRGB(44,44,44)
	lightning.Brightness = 0
	lightning.OutdoorAmbient = Color3.fromRGB(33,33,33)
	lightning.ClockTime = 0
end

function dayTime()
	lightning.Ambient = Color3.fromRGB(138,138,138)
	lightning.Brightness = 2
	lightning.OutdoorAmbient = Color3.fromRGB(148,148,148)
	lightning.ClockTime = 14
end

game.ReplicatedStorage.Folder.DayTime.Changed:Connect(function()
	if game.ReplicatedStorage.Folder.DayTime.Value == true then
		dayTime()
	else
		midnightTime()
	end
end)

The BoolValue changes on the Client Side as well as on the Server side but the script doesn’t do anything on the client side.

May I ask if this script is server or client side

It is on Server Side, a normal Script.

OK you just answered your own question

I’m confused, that didn’t answer any of my questions.
Server scripts are supposed to replicate to Clients as far as I remember.

Yeah but you should be doing it only the client not the server, unless you want every player to see this at once

That’s actually wrong lol, it also depends on where you put the Server Script, so you’d need to change it into a LocalScript instead

How do I know when things will replicate? Is there an article I can read?

Script

LocalScript

Check where each one works

LocalScripts work in a couple of specific areas, I think these are some:

  • StarterGui
  • StarterPlayerScripts
  • StarterCharacterScripts
  • StarterPack

While Server Scripts work anywhere really

You can also refer to the API references that Aylan gave

Actually, Server scripts work almost nowhere, only on workspace and SSS

Aaaaaaaa mb then, but preferably they run in Workspace (ServerScriptService is usually stored for Player & Character events, but don’t actually run just fires)

Finally got it to work. I don’t know why people told me it doesn’t replicate, perhaps replicate doesn’t mean what I thought it means. Just restarting the Studio got it to work, it all replicates to the clients now.