EDITED
Alright so I switched my LocalScript to RemoteEvent but I've encountered a script error 'attempt to index nil with name'.
What I'm trying to achieve: I want that when a player touches a specific part in the game, a script inside the part activates and sends a RemoteEvent signal to the player that touched the part, and the LocalScript inside the player changes the Lighting.ExposureCompensation
Server script:
function Touch(hit)
local part = script.Parent
local Players = game:GetService("Players")
local player = Players:GetPlayerFromCharacter(part.Parent)
local playername = player.Name
game.ReplicatedStorage.ExposureFired:FireClient(playername)
end
script.Parent.Touched:Connect(Touch)
Client/Local Script:
local function detected()
local entering = -2
local exit = 0
local lighting = game:GetService("Lighting")
if lighting.ExposureCompensation == entering then
lighting.ExposureCompensation = exit
elseif lighting.ExposureCompensation == exit then
lighting.ExposureCompensation = entering
end
end
game.ReplicatedStorage.ExposureFired.OnClientEvent:Connect(detected)

2 comments
Local Scripts do NOT run in workspace, the best directory for them is StarterPlayerScripts. Here it says all the places where local scripts run: https://developer.roblox.com/en-us/api-reference/class/LocalScript
Thank you for letting me know, I've edited the thread now since I've tried RemoteEvent instead but I still have a problem with the script.