Collision Groups not functioning correctly

Hello developers! A while ago I made a Collision Group script but its not working correctly. There are 8 collision groups named (Player1, Player2, Player3, Player4, Player5, Player6, Player7, Player8) and 8 groups named (Part1, Part2, Part3, Part4, Part5, Part6, Part7, Part8). Script needs to assign groups to Players and parts. Example: if someone join script will assing Player1 group to player and assing Part1 to Parts that player own and I set the groups like “Player1” group only can collide with “Part1” group. But when I test it a player that has “Player2” group can collide with part that has “Part1” Group. How can I fix? Here’s the script and some photos about the groups:


local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local LocalPlayer = Players.LocalPlayer

local partGroups = {"Part1", "Part2", "Part3", "Part4", "Part5", "Part6", "Part7", "Part8"}

local function getPlayerGroupIndex(player)
	local slotIndex = player:GetAttribute("PlayerCollisionSlot")
	return slotIndex
end

wait(0.1)

local function copyAllParts(playerIndex)
	if playerIndex then
		local partsToCopy = ReplicatedStorage.PushParts:GetChildren()
		for _, partToCopy in ipairs(partsToCopy) do
			local newPart = partToCopy:Clone()

			newPart.Parent = workspace

			local partGroup = partGroups[playerIndex]
			
			newPart.CollisionGroup = partGroup
		end
	end
end

local function setupPlayerParts()
	if not LocalPlayer:GetAttribute("PartsCopied") then
		local playerIndex = getPlayerGroupIndex(LocalPlayer)
		copyAllParts(playerIndex)
		LocalPlayer:SetAttribute("PartsCopied", true) 
	end
end


if LocalPlayer.Character then
	setupPlayerParts()
end


LocalPlayer.CharacterAdded:Connect(function(character)
	
	wait(1)
	setupPlayerParts()
end)