Help with client - lighting script

Hi, I made a script so that when a player touches a part the lighting changes but all players can see it and I only want the player who touched it can see it, I have tried changing it with a local script but it doesn’t work. Can someone tell me how to do it please? Thanks.

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		wait(.05)
		game.Lighting.Ambient = Color3.fromRGB(255, 255, 255)
		game.Lighting.Brightness = 0.15
		game.Lighting.ExposureCompensation = 1.25
	end
end)

script.Parent.TouchEnded:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		wait(.05)
		game.Lighting.Ambient = Color3.fromRGB(70, 70, 70)
		game.Lighting.Brightness = 0
		game.Lighting.ExposureCompensation = 0
	end
end)
2 Likes

You need to do this from the client with a LocalScript (make a LocalScript in StarterPlayerScripts).
You will also need to make sure that the humanoid is LocalPlayer’s humanoid.

if hit.Parent:FindFirstChild("Humanoid") and LocalPlayer.Character then
	if hit.Parent:FindFirstChild("Humanoid"):IsDescendantOf(LocalPlayer.Character) then
2 Likes

Hello, thank you for replying, now only the local player can see it, thanks!

1 Like