Such as Murder Mystery when all Innocents have died the game restarts. I do not know the process of that, anyone care to explain/demonstrate?
( I have the code thought out I just am struggling on figured this bit out. Any help would be appreciated)
Such as Murder Mystery when all Innocents have died the game restarts. I do not know the process of that, anyone care to explain/demonstrate?
( I have the code thought out I just am struggling on figured this bit out. Any help would be appreciated)
You would probably need a loop to set all values to true when the game starts:
local p = game.Players:GetPlayers()
for i = 1, #p do
p[i].Alive.Value = true
print(player.Name .. " is alive.")
end
And while the game is playing:
game:GetService('Players').PlayerAdded:connect(function(player)
local isAlive = Instance.new("BoolValue")
isAlive.Name = "Alive"
isAlive.Value = false
isAlive.Parent = player
player.CharacterAdded:connect(function(character)
character:WaitForChild("Humanoid").Died:connect(function()
print(player.Name .. " has died!")
player.Alive.Value = false
local numPlrAlive = 0
local p = game.Players:GetPlayers()
for i = 1, #p do
if p[i].Alive.Value then
print(player.Name .. " is still alive!")
numPlrAlive = numPlrAlive + 1
end
end
if numPlrAlive > 0 then
print("Players are still alive")
else
print("Everyone is dead!")
end
end)
end)
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.
2 comments
Thanks
+1