Getting both parts with touched event

I have this script that checks for when a part Tagged as a cameraRegion is touched,
How could I make it so I can get the part, as the function is assigned to multiple parts.
What I want to achieve is to get the specific camera region being touched so I can get some values stored in it.

local cs = game:GetService("CollectionService")

wait(3)
game:GetService("TweenService"):Create(game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame , TweenInfo.new(0.2) , {BackgroundTransparency = 1}):Play()
local Parts = cs:GetTagged("CameraRegion")

local functions = {}
local db = false


local function CameraSwitch(Otherpa)

	if db == false then
		db = true

		if game:GetService("Players"):GetPlayerFromCharacter(Otherpa.Parent) == game.Players.LocalPlayer then
			
			local player = game.Players.LocalPlayer
			local playerscripts = player.PlayerScripts
			local Cmera = playerscripts.Cmera

		end
		db = false
	end
end

for i , v in pairs(Parts) do
	v.Touched:Connect(CameraSwitch)
end

You could explicitly add additional arguments when you call that function:

for i , v in pairs(Parts) do
	v.Touched:Connect(function(otherPart)
        CameraSwitch(otherPart, v)
    end)
end
1 Like

Yeah that makes sense :slightly_smiling_face:

1 Like