Help with Touched

So, I’m making a sword. So, I’m using .Touched event to do this.
But, The weird thing is… The event doesn’t emit when It touched the player.
I have print the connection, the connection is assign.
But… It doesn’t emitted for some reason

here is my code

tool.HitPart.Touched:Connect(function(hit)
		print("Touched")
		if hit:FindFirstAncestorOfClass("Model") then -- Few checks to see if that is an NPC or a Player
			print("It is model!")
			local character = hit:FindFirstAncestorOfClass("Model")
			print(character.Name)
			local humanoid = character:FindFirstChild("Humanoid")
			if humanoid then
				print("It is humanoid")
				if player.Stamina.Value >= charge then
					print("Damaging the char")
					humanoid:TakeDamage(damage) -- Make the player damaged.
					playSound(hitId, tool)
					event:Disconnect()
				end
			end
		end
	end)

no errors.
Is there any solution?

Tell me which print statement fired and which print statement stopped firing.

All print statement in the touched event doesn’t even fired at all

Had you made sure this script is located where it suppose to be?

Yes, in server script. Not local script

Then maybe it’s something to do with your variables. Maybe you didn’t correct them or your part never hits anything.

The HitPart should be a BasePart of some sort, can you double check that there aren’t any errors showing up & you properly defined what tool is?

Also unrelated but The Hit parameter for the Touched Event returns back the BasePart, not the BasePart’s Parent

Yeah, Ik the hit parameter returns basepart. Also, HitPart is a basepart.

The thing is, do you really though?

In your conditional checks, you keep frequently checking for the hit of the BasePart, but not the hit.Parent's Object

A more visual example would be referred to as this for the Parents for checking a Character:

BasePart (NOT THE MODEL) > Character Model > workspace > game

If you’re wanting to get the Character, you have to reference hit.Parent & check if it’s a valid Player or not

tool.HitPart.Touched:Connect(function(hit)
	print("Touched")

	if hit.Parent:FindFirstAncestorOfClass("Model") then
		print("It is model!")
		local PlayerCheck = game.Players:GetPlayerFromCharacter(hit.Parent)

		if PlayerCheck then
			local Character = hit.Parent
			local Humanoid = Character:WaitForChild("Humanoid")
			print("It is humanoid")
			if PlayerCheck.Stamina.Value >= charge then
				print("Damaging the char")
				Humanoid:TakeDamage(damage)
				playSound(hitId, tool)
				event:Disconnect()
			end
		end
	end
end)

Even the touched doesn’t printed so that’s not a problem

Also, you’re using FindFirstAncestorOfClass not IsA.

You included that in your original script though?

Could it be possible that you have the CanTouch properly disabled? Check your properties to ensure that isn’t the case

Property CanTouch is enabled. I’ve run some tests. Turns out, the part never touches anything.
So, I move on to raycast and it worked!

i think u made ur self do way more work then u have to do so heres a simple thing that could help u!
tool.HitPart.Touched:Connect(function(hit)

local char = hit.Parent
local humanoid = char:FindFirstChildWhichIsA("Humanoid")
if humanoid then
	humanoid.Health = 0
	print(char.Name .. "Has Died LOL")
end

end)

Could you include a place file for this if possible? This is strange unexpected behavior, especially if the Part you’re trying to detect is a BasePart object of some sort

yes, but I’m trying to look for the ancestor. because that hit might be not the child of the character. Just in case that hit is not the child of the character, but the descendant of the character. That’s why I use FindFirstAncestorOfClass

that place isn’t owned by me, I worked for someone else to make a sword. He didn’t allowed me to save the place into my pc. :sad:

Oh ok sorry about that. Lollol