What do you want to achieve?
The win conditions to activate properly
What is the issue?
In a 2 player game, the first condition always activates no matter what
In a 3+ player game, the second condition always activates when anyone dies
What solutions have you tried so far?
I’ve searched the forums yesterday and just implemented it yesterday too
I think the problem may be the find variable turning nil when just one person dies
--Adds players to table an removes them when they die
for _,player in pairs(game.Players:GetChildren()) do
local char = player.Character
char:WaitForChild("Humanoid").Died:Connect(function()
local index = table.find(players,char.Name)
table.remove(players,index)
end)
end
--RoundTimer
for i = roundlength,0,-1 do
InRound.Value = true
task.wait(1)
status.Value = i
local vamp = script.Parent.NormalRoles.Vampire
local find = table.find(players,vamp.Value,1)
wait(Wait)
Wait = 0
if find == nil and table.getn(players) >= 2 then
print("Vampire is dead, One player is left")
End:FireAllClients("Humans",vamp)
task.wait(4.5)
TimeOut = true
break
elseif find == nil and table.getn(players) <= 1 then
print("Vampire is dead")
End:FireAllClients("Humans",vamp)
task.wait(4.5)
TimeOut = true
break
elseif find ~= nil and table.getn(players) <= 1 then
print("Vampires won")
End:FireAllClients("Vampires",vamp)
task.wait(4.5)
TimeOut = true
break
end
end