Событие Roblox Died не вызывается, даже если здоровье игрока <0 - PullRequest
0 голосов
/ 08 апреля 2020

Я пытаюсь добавить очки игроку, когда он убивает другого игрока.

Когда моя пуля, выпущенная игроком 1, попадает в игрока 2, здоровье P2 уменьшается и становится равным 0 и минус значения при последующих попаданиях.

Но функция Humanoid:died() не вызывается, когда здоровье P2 достигает 0.

Может кто-нибудь помочь с этим?

PS - то же самое событие происходит, когда я убиваю человека с мечом модели. И меч, и пистолет используют только функции 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)```

The gun model is something That I imported from online
It had `TakeDamage()` function used inside it.

I just added the model to `starterPack` and started using it.
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...