Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do i make it disable when everyone is dead

local rp = gt[math.random(1,#gt)]
local gt = game.Players:GetPlayers()


for _,Player in pairs(gt) do -- For all the players
   if not Player == rp then -- If player is not the randomly selected player
       if Player.Humanoid ~= 0 then --what im trying to do is if all the players are dead then it will restart the script...
			h.Text = "NOOOOO "			
			script.Archivable = false
			script.Disabled = true
			wait()
			script.Disabled = false
			script.Archivable = true	
		end
	end
end

but it doesnt seems to work, so i'd hope one of you guys could try helping me

1 answer


local gt = game.Players:GetPlayers()
--You had rp, before gt was defined. 
local rp = gt[math.random(1,#gt)]

local function findAll()
	for _,Player in pairs(gt) do -- For all the players when the script first grabbed them.
	   if Player ~= rp then -- If player is not the randomly selected player
	       if Player.Character.Humanoid.Health ~= 0 then -- 
	            return true
	        end
	    end
	end
	return false
end

--This should be run every time someone dies, via something like your leaderboard script. 
if findAll() then 
	print("Someone is still alive.")
else
	print("Everyone is dead")
	h.Text = "NOOOOO "    
	--This is very bad vvvv      
	script.Archivable = false
	script.Disabled = true
	wait()
	script.Disabled = false
	script.Archivable = true
end

2 comments

0

However, it is important to know that if their humanoid is removed, or they respawn, this script will not function as expected.

0

hmmh, its not working -.-

This discussion is preserved as it was. New answers, comments, and votes are closed.