Sorry if this is a stupid question but I am new to scripting I have some confusion about the touched event.
So if I want to make a player lose health when he touches a block, I use this:
script.Parent.Touched:Connect(function(hit)
local hum = hit.Parent:FindFirstChild("Humanoid")
if hit.Parent:FindFirstChild("Humanoid")then
hum.Health = hum.Health - 10
end
end
I am just confused as to how this works. How does the block search for the "Humanoid". Also the parameter "hit" do we include this as it is a only local to the block? If anyone could help me understand, perhaps explain how this all functions. I would really appreciate it. Thank you.

3 comments
Ok so when the player touches the block, is the script applied to them and thats how hit is able to find the "FindFirstChild" "Humanoid"?
Yes script is applied to one part of their body and that's how you get the player. In case you want to get player from it you would do
local Player = game.Players:GetPlayerFromCharacter(hit.Parent)