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)
SOLVED:
I asked this question in a developer discord server and they gave me a solution.
Code by Senko-san#0001:
local lighting = game:GetService("Lighting") game.Workspace.Changer.Touched:Connect(function() local entering = -2 local exit = 0 if lighting.ExposureCompensation == entering then lighting.ExposureCompensation = exit elseif lighting.ExposureCompensation == exit then lighting.ExposureCompensation = entering end end)