How to check if all players are dead in the folder but not the tiger?

before round starts it resets the values to false and make a random player Tiger I always do reset function for values its so good

1 Like

do NOT use for _, player in

If you do so, you have to check every frame (unless some specific situations where you KNOW you only need to check it once)

Instead, its better to merge all attributes into one (no matter as a table or as a int), and then use .Changed

No, It’s okay to use It dosen’t check every frame it loops into every player to see if he is killed or escaped or has secret ending I would make it a function. When the game ends I spawn this function.

Probably there should be a table contains Players in game to avoid spectators
Players = { }

That would require only ending the game based on a timer or other stuff. Which could cause everyone to be dead long before the game ends. If you want to use player death as a way of ending the game (or player escaping), you’d need to constantly check

3 Likes

you don’t need to kill players lol :LoadCharacter()?

1 Like

what?

I dont see how I talked anything about killing the player…

You’d still not be able to detect if the player “died”?

3 Likes

I didn’t understand your reply but, developer can manually set the death value to true or false and remove the player from ingame table like:

local InGamePlayers = {}
local Connection = {}

local function CheckPlayerStatus(Player)
            if Player:GetAttribute("IsKilled") == true then
                --> After Code / Cutsene
            Player:LoadCharacter()
       elseif Player:GetAttribute("IsEscaped") == true then
              --> After Code / Cutsene
            Player:LoadCharacter()
       elseif Player:GetAttribute("IsSecretEndingAchieved") == true then
              --> After Code / Cutsene
            Player:LoadCharacter()
       end
end

while true do
      print("Intermission")
      task.wait(5)
      print("InGame")
      for _, Player in game.Players:GetPlayers() do
          table.insert(InGamePlayers, Player)
      end

      for _, Player in InGamePlayers do 
           Connection[Player] =  Player.Character.Humanoid.Died:Connect(function()
                   Player:SetAttribute("IsKilled", true) 
            end)
      end 
      task.wait(50)
      for _, Player in InGamePlayers do 
           CheckPlayerStatus(Player)
            ResetPlayerAttributes(Player) --> Resets Attributes to it's default value
            table.remove(InGamePlayers, Player)
            Connection[Player]:Disconnect()
      end

      print("Cleanup")
end
2 Likes
local playerModule = require(script.player)
local roundInfo = game:GetService("ReplicatedStorage").RoundInfo
local gamePlayers = roundInfo.Players
for _,v in pairs(gamePlayers:GetChildren()) do
	if v.Value ~= "Alive" then
		playerModule.showAllCutscene(game.ReplicatedStorage.ChapterValues.CutsceneChapter.Value, "Outro")
		roundInfo.Timer.Value = 0
		roundInfo.Status.Value = ""
	end
end

so I did this and in another script I am doing a Boolvalue into the value of the player in the gameplayers which is the tiger so how would I check if everyone is not alive but not the tiger?

3 Likes

I don’t know what you store in the roundInfo instance or gamePlayers instance and the values inside it but if you have a tigerboolean check if player is not tiger and is not alive and check if it’s tiger and alive or else like that:

local playerModule = require(script.player)
local roundInfo = game:GetService("ReplicatedStorage").RoundInfo
local gamePlayers = roundInfo.Players

for _,v in pairs(gamePlayers:GetChildren()) do
	if v.Value ~= "Alive" and v.Tiger.Value ~= true then
		--> Do Something
	end

	if v.Alive == "Alive" then
		if v.Tiger.Value == true then
			--> Do Something
		elseif v.Tiger.Value == false then
			--> Do Someting
		end
		
	elseif v.Value ~= "Alive" then
		if v.Tiger.Value == true then
			--> Do Something
		end
	end
end

I don’t know how your game works and what it contains you can check community tutorials and I hope your problem is fixed.

3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.