Why does hit.parent work and not just humanoid

Right now I am working on a sword script. The part I am confused about is the humanoid. When I use hit.parent it will damage the dummy the sword hits but when I use my predefined humanoid at the very top it will damage my character.

local lcPlayer = players.LocalPlayer
local hum = lcPlayer.Character.Humanoid

local katana = script.Parent
local hitBox = katana.BladeHitbox
local canAttack = true
local cooldown = 3
local canDamage = true

local slashAnim = katana.Animation
local animTrack =	hum:LoadAnimation(slashAnim)

local UIS = game:GetService("UserInputService")

local function DamagePlayer(hit)
	if animTrack.IsPlaying then
		if hum and canDamage == true then
			local humanoid = hit.Parent.Humanoid 
				humanoid.Health = humanoid.Health-10

	if input.UserInputType == Enum.UserInputType.MouseButton1 then
		if canAttack == true then
			canAttack  = false --Player can't attack or stop anim

This is because the humanoid at the top is your localplayer’s humanoid, which is you. When you use a touched event and get the humanoid, it gets the humanoid of whatever touched it; which would be your opponent.

1 Like

btw in addition to this, damaging other players from a LocalScript will not replicate, aka it will not damage other players.

1 Like

Ok thank you. Last question would I have to use regular script then?

Thank you for your help! I figured it might be something like that but I wasn’t completely sure and I wanted to check.

1 Like

Yes. A script is serversided. A localscript is clientsided