So what I'm trying to do is make it so the when everyone but one person dies before the time's up, that person will be the winner or when 2 or more people survive the round ,they will be the winner.
The problem is, I'm extremely confused.
This should work
Script:
local diedEvent = Instance.new("RemoteEvent" , game.ReplicatedStorage) diedEvent.Name = "Died" local playersalive = game.Players:GetChildren() diedEvent.OnServerEvent:Connect(function(plr) local plrname = plr.Name for i,v in ipairs(playersalive) do if v.Name == plrname then table.remove(playersalive , i) end end end) while true do wait() local index = #playersalive if index == 1 then print (playersalive) end
LocalScript:
game.Players.LocalPlayer.Character.Humanoid.Died:Connect(function() game.ReplicatedStorage.Died:FireServer() end)
This should require multiple scripts: 1. Insert a number value (call it Countdown) in workspace 2.Make a countdown for round script A. I won't provide you with one, customize it 3. In workspace, add a folder called Characters 3. Add script in it:
game.Players.PlayerAdded:connect(function(Player) local Plr = Instance.new("StringValue", script.Parent) Plr.Name = Player.Name Plr.Value = Player.Name Player.CharacterAdded:connect(function(Char) Char.Humanoid.Changed:connect(function(Change) if Change == "Health" then if workspace.Countdown.Value > 0 then if Char.Humanoid.Health <= 0 then Plr:remove() if script.Parent:GetChildren()[3] ~= nil then local Plrs = game.Players:GetChildren() for i, v in ipairs(Plrs) do if script.Parent:FindFirstChild(v.Name) ~= nil then --Player wins end end end end end end end) end) end))
Thanks for providing me with this challenge, I'll use this script myself