Will this only affect the player that clicks the button?

Basically, i’am using this code:

local Day = true

script.Parent.MouseButton1Click:Connect(function()
	Day = not Day
	if Day == false  then
		game.Lighting.TimeOfDay = 00,00,00
	else
		game.Lighting.TimeOfDay = 12,00,00
	end
end)

Its an local script, inside a Text Button, when someone clicks it, they make the game night or day.

The “issue”, is that i don’t know if it will apply to everyone, instead of only the player who clicks it, can someone answer it?

If the script is Local, then it will only be for one client. Server scripts apply changes for everyone.

1 Like

[30 charsssssssssssssssssssssssss]

1 Like

You need to use remotes. Also, that code will not work as you expect. Lighting.TimeOfDay expects a string. And what you are doing is assigning it to 0 or to 12, not 12:00. Use Lighting::SetMinutesAfterMidnight instead.

Implementation via remotes is trivial: Custom Events and Callbacks | Documentation - Roblox Creator Hub

2 Likes

I keep checking the link you gave,i just made an Player joined/Player left message, and thank you! Also, it still works tho.

1 Like

It’s not like there is a link for everything you want to script. You are going to have to learn how to change the code to work how you want.

2 Likes

I actually have other issue, before making this post, i thought of using remote events, but we usually use an Script, and a LocalScript, but i’am going to use localplayer to get the player, meaning i would have to use an local script, so this would also mean i would need to use an localscript and other localscript? Or i can use PlayerAdded?

1 Like

If it is in LocalScript, only the Customer will be able to see ,it now if it’s a script everyone will see it.

1 Like

Have you tried using remotes? It should solve your solution into this script.

If you are going to get the player in LocalScript, you can use

local Plr = game.Players.LocalPlayer

and thus pass the player through the remote event

RemoteEvent:FireServer(Plr)

Thanks!

I already solved my issue, also, i marked his post as the solution.