我想做一个枪战的demo,如何检测玩家死亡,死亡者是如何知道是被谁打死的
求大神指点
查看humanoid相关文档。 里面有生命值这个属性。 还有死亡的事件、受到伤害的事件等等。
记录一下攻击来源的玩家 就可以知道是被谁打死的。
game.Players.PlayerAdded:Connect(function(obj)
print(1)
obj.CharacterAdded:connect(function(characher)
print(2)
characher.Humanoid:Died(function(diedPlayer)
print('死亡')
print(diedPlayer)
end)
end)
end)
Died is not a valid member of Humanoid “Workspace.Robloxianc5l7j0b2b.Humanoid”
这样提示找不到Died 方法
这个 你先看看官方教程吧 学习下基础
game:GetService(‘Players’).PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
character:WaitForChild(‘Humanoid’).Died:Connect(function()
print(player.Name…'has died! ')
end)
end)
end)