Issues with Collection Service and my Script (Any Ideas Welcome)

Hello everyone! I have an interesting problem, an issue with no error message.

  1. What do you want to achieve?
    I have a system that uses collection service to monitor touched events with parts. The amount of parts scales, as each player in the game can have up to around 40 tagged parts. Currently, I do not expect any issues with this amount. However, my code does not work.
  2. What is the issue?
    My code looks like this:
    A side function for deleting and manipulating things:
local function destroyCell(Cell, Player)
		if Cell.cellValue == 1 then
			local bCount = Player.pData:FindFirstChild("bCount")
			bCount.Value = bCount.Value - 1
		end
		if Player.pData.bCount == 0 then
			--FIRE CLIENT AND END GAME
			local cells = workspace:FindFirstChild(Player.UserId .. "_cells")
			local mainBCell = exBCell:Clone()
			mainBCell.Parent = cells
			mainBCell.Name = "mainBCell"
			PhysicsService:SetPartCollisionGroup(mainBCell, "Spectating")
			mainBCell.Transparency = 1
			mainBCell.Orientation = Vector3.new(0,0,90)
			mainBCell.Position = Vector3.new(-2.869, 1.738, 5.894)
			mainBCell:SetNetworkOwner(Player)
			GameEndEvent:FireClient(Player)
		end
		Cell:Destroy()
	end

The main code (please note that if you have any questions, I will be happy to answer them below.):

for _, TaggedPart in pairs(TaggedParts) do
	TaggedPart.Touched:Connect(function(hit)
		local cell = TaggedPart
		local cells = TaggedPart.Parent
		local cValue = TaggedPart.cellValue
		local pID = string.gsub(cell.Parent.Name, "_cells", "")
		local player = Players:GetPlayerByUserId(pID)
		if hit:IsDescendantOf(cells) then return end
		if hit.Name == "brainCell" or hit.Name == "toothCell" or hit.Name == "skinCell" or hit.Name == "mainBCell" then
			if string.match(hit.Parent.Name, "_cells") ~= nil then
				local hID = string.gsub(hit.Parent.Name, "_cells", "")
				local hplayer = Players:GetPlayerByUserId(hID)
				local hValue = hit.CellValue
				local points = player.leaderstats.Points
				local hpoints = hplayer.leaderstats.Points
				if pID ~= hID then
					if hValue.Value > cValue.Value then
						hpoints.Value = hpoints.Value + cValue.Value
						destroyCell(cell, player)
					end
					if hValue.Value == cValue.Value then
						points.Value = points.Value + hValue.Value
						hpoints.Value = hpoints.Value + cValue.Value
						destroyCell(cell, player)
						destroyCell(hit, hplayer)
					end
					if hValue.Value < cValue.Value then
						points.Value = points.Value + hValue.Value
						destroyCell(hit, hplayer)
					end
				end
			end
		end
	end)
end
  1. What solutions have you tried so far?
    With my other post, Print() deciding if my code works or not, I attempted to see what was wrong with my other code in the script. (Nothing actually, after I shifted this code to another script.) This leads me to believe that something is wrong with this specific code.

Important Information: I am getting no errors in the output log. Iā€™m not sure what this means.

Any and all help is appreciated! Thanks again for reading and replying!
Someperson576

It appears that nothing is wrong, and I finally got it to work. I simply had to keep updating the collection service list.

1 Like