Hey there.
So I'm making a tool, that when activated, does damage to a player when the handle of the tool is touching him. I'm also trying to do it in a way that only a one hit is detected when you activate the tool so that the player doesn't die immediately.
But for some reason what happens is that the hits on a player are very rarely detected. Like sometimes it detects and sometimes it doesn't.
I'll be really glad if someone could help me.
Here is the script:
local tool = script.Parent
local handle = tool.actualHandle
local targetHumList = {}
handle.Touched:Connect(function(part)
if part.Parent:FindFirstChildWhichIsA("Humanoid") then
local targetHum = part.Parent:WaitForChild("Humanoid")
if targetHum and targetHum.Health > 0 and
table.find(targetHumList, targetHum) == nil then
table.insert(targetHumList, targetHum)
targetHum:TakeDamage(10)
end
end
end)
tool.Activated:Connect(function()
targetHumList = {}
end)

2 comments
As far as I know ".touched" can sometimes be unreliable, I've encountered the same problem before. Unfortunately, Im not very experienced so Im not sure what alternative you could use.
To make it slightly more detectable I would use :IsDescendantOf(theirchar), this also might be because of the hitbox size of the tool.