One of my scripts for a game is supposed to check if a player died and when a player dies to make a value set to true. It doesn’t work right and I was wondering how I can fix it.
function getPlayerStatus(Status)
print("end me")
local a = 0
local people = game.Players:GetPlayers()
for i = 1,#people do
if people[i]:findFirstChild("Dead") then
if people[i].Dead.Value == Status then
a = a + 1
end
end
end
print(a)
return a
end
Can’t you just use the Humanoid.Died function instead? You can implement a conditional check if the Dead.Value check is false, then set it to true afterwards
local DeadPlayers = 0
game.Players.PlayerAdded:Connect(function(Player)
local DeadCheck = false
Player.CharacterAdded:Connect(function(Character)
local Humanoid = Character:WaitForChild("Humanoid")
Humanoid.Died:Connect(function()
if DeadCheck == false then
DeadPlayers += 1
print(Player.Name.." has died!")
DeadCheck = true
else
print(Player.Name.." has already died!")
end
end)
end)
end)
You could pretty much implement what you wanna do with this when a Player’s Character dies