Roblox死亡事件未被触发,尽管玩家健康值小于0

我试图在玩家杀死另一个玩家时添加积分。

当由Player1发射的子弹击中Player2时,P2的健康值会减少并变为0,并在随后的击中中变为负值。

但是,当P2的健康值降至0时,“Humanoid: died ()”函数并未被调用。

有人能帮忙吗?

附言-使用剑模型杀死人时触发相同的事件。 剑和枪都仅使用“takeDamage()”函数。

非常感谢任何帮助。

带有'DIED() '事件的代码


    local leaderstats = Instance.new("Folder")
    leaderstats.Name = "leaderstats"
    leaderstats.Parent = player

    local bucks = Instance.new("IntValue")
    bucks.Name = "Points"
    bucks.Value = 0
    bucks.Parent = leaderstats

    player.CharacterAdded:Connect(function(character)
        wait(2)
        character.Humanoid.Health = 2
        character.Humanoid.MaxHealth = 2
        character.Humanoid.WalkSpeed = 50

        character.Humanoid.HealthChanged:Connect(function(health)
            print("health change event triggered")
        end)

        character:WaitForChild("Humanoid").Died:Connect(function()
            -- when someone dies

            print("camhere to the died Connect function")
            print(tostring(character.Humanoid.creator.Value))

            if character.Humanoid and character.Humanoid:FindFirstChild("creator") then
                game.ReplicatedStorage.Status.Value = tostring(character.Humanoid.creator.Value).." KILLED "..player.Name.."!"
                local killerName = tostring(character.Humanoid.creator.Value)
                print("camhere")
                for i,player in pairs(game.Players:GetPlayers()) do
                    if  player and player.Name == killerName then
                        player.leaderstats.Points.Value = player.leaderstats.Points.Value + 1
                        print("here too")
                    end
                end
            end

            if character:FindFirstChild("isAlive") then
                character.isAlive:Destroy()
            end

            player:LoadCharacter()
        end)

    end)
end)```

枪模型是我从网上导入的东西
里面使用了 'TakeDamage ()' 函数。

我只是将模型添加到 'starterPack' 并开始使用它。
点赞