Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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)

2 comments

0

you can't

0

r u sure its a local script

2 answers

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.

1 comment

0

it still affects the whole server's lighting :/

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.