Hey everyone, firstly if it ends up being needed I am fine providing the entirety of the script- but for now I have omitted what I think is not important.
The round system for my game works in the following way:
ROUND SYSTEM
- Wait for players, then start round
- Monitor players who have no yet died until only the survivor and killer remain
- When only one survivor is left, force last survivor and killer into a duel
- Once either player wins the duel return everyone to lobby
- Repeat
(further context can be provided for any of this if confusing)
The issue I am currently experiencing is that no matter what approach I take - my array of remaining players seems to be inaccurate most of the time, and the duel never starts (aka the array never has only a single survivor remaining - even if all other survivors have died, so I am somehow monitoring deaths incorrectly)
Simplified round code (yes some of this will eventually be moved into modules):
function StartArena(Map, Killer, Survivor) -- eventually jetpacks & sword will instead read from playerdata
local KillerJetpack = ReplicatedStorage.Jetpacks.Default:Clone()
local SurvivorJetpack = ReplicatedStorage.Jetpacks.Default:Clone()
local KillerSword = ReplicatedStorage.Weapons.LinkedSword:Clone()
local SurvivorSword = ReplicatedStorage.Weapons.LinkedSword:Clone()
Survivor.Character:SetPrimaryPartCFrame(Map.ArenaSurvivorSpawn.CFrame * CFrame.new(0, 4, 0))
Killer.Character:SetPrimaryPartCFrame(Map.ArenaKillerSpawn.CFrame * CFrame.new(0, 4, 0))
KillerJetpack.Parent = Killer.Character
SurvivorJetpack.Parent = Survivor.Character
KillerSword.Parent = Killer.Backpack
SurvivorSword.Parent = Survivor.Backpack
end
function RoleDecision()
local PlayerList = Players:GetChildren()
local KillerNum = Random.new():NextInteger(1,#PlayerList)
local Killer1 = PlayerList[KillerNum]
table.remove(PlayerList, KillerNum)
for _,v in pairs(PlayerList) do
UpdateSpecificUI(v, "Role", "Survivor")
end
UpdateSpecificUI(Killer1, "Role", "Garbage Man")
return Killer1, PlayerList
end
function Update(...)
local Table, Player = ...
for i,v in pairs(Table) do
if Player == v then
table.remove(Table, i)
return
end
end
end
local PickedMap = ReplicatedStorage.Maps:GetChildren()[Random.new():NextInteger(1, #ReplicatedStorage.Maps:GetChildren())]
local NewMap = PickedMap:Clone()
NewMap.Parent = game.Workspace
local Killer, Survivors = RoleDecision()
TeleportFunction(NewMap, Killer, Survivors)
for i,player in pairs(Survivors) do
player.Character.Humanoid.Died:Connect(function()
Update(Survivors, player)
print(#Survivors .. " remain! " ..player.Name .. " has died!")
end)
end
repeat safeWait(.003) until #Survivors <= 1
Once more, a lot is missing from this because I assume the error exists within these code portions, but more can be provided. Script is located in SSS.
Any help is appreciated, thank you all. I’ve only recently returned to Roblox and started coding again, so it is very possible the problem is quite simple. =)