Damage Script doesnt work

I wanted to try to make a damage script for when an npc touches a player they take damage. So I wrote my own script but it only damaged the player once. When I wrote it differently it didn’t damage the player at all.

Desperate for help I looked up on the dev forum or youtube tutorials but none of them worked or was related to what I wanted to add.

Here is the script I used. Its not really my own because I tried to look on dev forum and youtube for help. But yeah, you get the idea.

--local lhand = script.Parent.LeftHand
local rhand = script.Parent.RightHand

local function onTouch(otherPart)
	local hum = otherPart.Parent:FindFirstChild("Humanoid")
	if hum then
		hum:TakeDamage(10)
	end
end

torso.Touched:Connect(onTouch)
rhand.Touched:Connect(onTouch)
lhand.Touched:Connect(onTouch) 
2 Likes

Are you getting an error? You commented out lhand in this code snippet which would error since you are referencing it in the last line.

2 Likes

I’m not getting an error.
Should I remove the lhand?

Where is this script in the explorer?

Is that the whole script? We aren’t able to see if you defined torso either. Is this script a server script or a local script?

You know I think I should just start over. Either way thanks for the help.

If you’re using R15, then there isn’t a torso part which is breaking the script. It’s UpperTorso and LowerTorso

Thanks it worked. I altogether removed the torso part and it worked. :happy1: