If itβs a local script, it will only change on the client, so the server will not see it. If you want it to be seen by the server, you will need to fire a remote event.
You have to detect the clicking client-sidedly then send a message through a remote event, receive that message from the server. Then change it server sidedly.
If you do not do this exactly it will not working, due to a few points:
Changing a value client-sidedly will not update server-sided scripts, so it wont update other players.
Detecting a mouse click on a GUI object can only be detected by a client-sided script.
Client-sided script:
local RemoteEvent = game:GetService("ReplicatedStorage"):WaitForChild("EventName")
function OnClicked()
RemoteEvent:FireServer(script.Parent.Parent.Parent.Parent.Body.Lights.On)
end
script.Parent.MouseButton1Down:connect(OnClicked)
Server-sided script:
local RemoteEvent = game:GetService("ReplicatedStorage"):WaitForChild("EventName")
RemotEvent.OnServerEvent:Connect(function(player, valueToToggle)
-- Toggle the light here.
valueToToggle = true
end)
If you do not know how RemoteEvents work, I highly suggest to deepen yourself in this subject.