Mobile Select System Glitchy

So I am making a select system for my training UI and I want it to be mobile compatible. but it is very glitchy such as if I select a player it may select another character sometimes it may not even unselect a character.

I used this method to get the character from mobile:

My Code:

UIS.TouchTapInWorld:Connect(function(pos, gp)
	print("fired-mobile")
	if gp then return end
	local ray = Camera:ViewportPointToRay(pos.X, pos.Y, 0)
	ray = Ray.new(ray.Origin, ray.Direction * 500)
	local Target = workspace:FindPartOnRayWithIgnoreList(ray, Filter)
	if Target then
		if Target.Parent:FindFirstChild("Humanoid") and Selecting == true then
			local Character = Target.Parent
			if not Character:FindFirstChild("SelectionBox") then
				local Box = Instance.new("SelectionBox", Character)
				Box.Adornee = Character
				Box.Color3 = Color3.fromRGB(255, 170, 0)
				Box.LineThickness = 0.05
				Box.Transparency = .5
				table.insert(Selected, Character.Name)
				updateSelected()
			else
				Character:FindFirstChild("SelectionBox"):Destroy()
				local index = getIndex(Selected, Character.Name)
				table.remove(Selected, index)
				updateSelected()
			end
		end
	end
end)

updateSelected() is a function that gets the table and outputs the results on the gui on the left side of the screen

Video of what it is like for mobile: