Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make this script work locally and not globally?

Asked by 5 years ago

Hey, I have this script that toggles a color correction effect on/off via a gui however when toggled the whole server's lighting changes - so if one player toggles it off, it is also toggled off for another player but I'd like it to be turned on/off locally so the lighting is local so players can choose whether they want the effect on/off.

local Button = script.Parent
local lighting = game:GetService("Lighting")

function onClick()
    lighting.ColorCorrection.Enabled = not lighting.ColorCorrection.Enabled
end

Button.MouseButton1Click:connect(onClick)

0
you can't DeceptiveCaster 3761 — 5y
0
r u sure its a local script Gameplayer365247v2 1055 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago

I think the best way to do this is to make the ColorCorrection on the spot. Just Instance.new the ColorCorrection. I am not sure if it's gonna work though.

0
it still affects the whole server's lighting :/ LouieN07 16 — 5y
Ad
Log in to vote
0
Answered by
Azarth 3141 Moderation Voter Community Moderator
5 years ago
Edited 5 years ago

Place ColorCorrection in the Players camera.

local Button = script.Parent
local LocalCamera = workspace.CurrentCamera
local ColorCorrectionObject = LocalCamera:FindFirstChild("ColorCorrection")

if not ColorCorrectionObject then 
    ColorCorrectionObject = Instance.new('ColorCorrectionEffect')
    ColorCorrectionObject.Brightness = 1
    ColorCorrectionObject.Parent = LocalCamera
end

Button.MouseButton1Click:Connect(function()
    ColorCorrectionObject.Enabled = not ColorCorrectionObject.Enabled
end)

Answer this question