Help with CollectionService

I’m having a problem with AddTag of CollectionService, when i use it the tag dont appear and don’t work the rest of the script.

collection = game:GetService("CollectionService")

game.Players.PlayerAdded:Connect(function(playerr)
	playerr.CharacterAdded:Connect(function(char)
		for i, v in pairs(char:GetDescendants()) do
			if v:IsA("Humanoid") then
				print("go")
				collection:AddTag(v, "KillNoobs") -- Problem: not adding the tag "KillNoobs"
				local taketag = collection:GetTagged("KillNoobs")
				if collection:HasTag("KillNoobs") then
					repeat
						wait(1.5)
						taketag:TakeDamage(10)
						print("Hit")
					until taketag.health < 20		
				end	
			end
		end
	end)
end)

Please help me ;(

:GetTagged(tag) returns a table of instances that has the tag you give it. If you want to get a specific instance from that table you can iterate through it using a for loop.

				if collection:HasTag("KillNoobs") then

You need to pass the instance in here first!

Also here

This is saving a list of the current tags, not all.

This will also probably leak this loop.

Thanks for answering, i didn’t know these things, but i’m having another problem with this:

image

Why i need to click to activate de Tag?