Okay so I'm trying to create a script that checks when a player has killed another player or Npc here's what i got.
if part then -- 'part' is the raycasting bullet local humanoid = part.Parent:FindFirstChild("Humanoid") local head = part if not head then end if head and head.Name == "Head" then local debounce = false head.Parent:FindFirstChild("Humanoid"):TakeDamage(25) if humanoid.Health == 0 and not debounce then debounce = true player.leaderstats.Kills.Value = player.leaderstats.Kills.Value + 1 wait(3) debounce = false end end if not humanoid then humanoid = part.Parent.Parent:FindFirstChild("Humanoid") end if humanoid then humanoid:TakeDamage(6) end if humanoid.Health == 0 then -- This is where i get all my errors from local playerw = game.Players:GetPlayerFromCharacter(part) playerw.leaderstats.Kills.Value = player.leaderstats.Kills.Value + 1 end end
I would use the humanoid Died function for this. I think you would replace if humanoid.Health == 0 then
with humanoid.Died:connect(function()
Not sure if it'll work, I haven't tested it yet.