Local script for changing ColorCorrection values affects all players

I have made a local script inside startercharacter that when you touch a part, it changes the values of ColorCorrection inside of Workspace.CurrentCamera, but when a player touches a part the values change for all players. I do not want this, and I don’t know what’s the issue

According to a guy that tried to help me, CurrentCamera is shared? If so then why does a local script that changes the tintcolor of another ColorCorrectionEffect in CurrentCamera when taking damage working correctly?

Maybe the touched event fires for all clients?

local folder = game.Workspace.Regions

local mirage = folder.Mirage
local rust = folder.RustBelt
local sand = folder.Sandstone

local TS = game:GetService("TweenService")

local Tweeninfo = TweenInfo.new(3, Enum.EasingStyle.Quart, Enum.EasingDirection.Out)

local mirg = false
local rusty = false
local sandy = false
local ccorrection = Instance.new("ColorCorrectionEffect", game.Workspace.CurrentCamera)
ccorrection.Name = "ccRegion"

mirage.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") and not mirg then
		mirg = true
		rusty = false
		sandy = false
		local tween = TS:Create(ccorrection, Tweeninfo, {TintColor = Color3.fromRGB(255, 255, 160), Saturation = 0})
		tween:Play()
	end
end)

rust.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") and not rusty then
		mirg = false
		rusty = true
		sandy = false
		local tween = TS:Create(ccorrection, Tweeninfo, {TintColor = Color3.fromRGB(230, 230, 255), Saturation = -0.3})
		tween:Play()
	end
end)

sand.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") and not sandy then
		mirg = false
		rusty = false
		sandy = true
		local tween = TS:Create(ccorrection, Tweeninfo, {TintColor = Color3.fromRGB(255, 255, 160), Saturation = 0})
		tween:Play()
	end
end)
1 Like

It isn’t, how can a player share their camera view with others?

That’s correct, make sure if the player that touches it is the local player:

mirage.Touched:Connect(function(hit)
	local plr = game.Players:GetPlayerFromCharacter(hit.Parent) -- find player that touched the part
if not mirg and plr and plr == game.Players.LocalPlayer then -- check if player exists and player matches localPlayer
		mirg = true
		rusty = false
		sandy = false
		local tween = TS:Create(ccorrection, Tweeninfo, {TintColor = Color3.fromRGB(255, 255, 160), Saturation = 0})
		tween:Play()
	end
end)

rust.Touched:Connect(function(hit)
	local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if not rusty and plr and plr == game.Players.LocalPlayer then
		mirg = false
		rusty = true
		sandy = false
		local tween = TS:Create(ccorrection, Tweeninfo, {TintColor = Color3.fromRGB(230, 230, 255), Saturation = -0.3})
		tween:Play()
	end
end)

sand.Touched:Connect(function(hit)
	local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if not sandy and plr and plr == game.Players.LocalPlayer then
		mirg = false
		rusty = false
		sandy = true
		local tween = TS:Create(ccorrection, Tweeninfo, {TintColor = Color3.fromRGB(255, 255, 160), Saturation = 0})
		tween:Play()
	end
end)
2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.