im trying to make a round system alongside with a juggernaut system
the juggernaut system doesnt work for some reason, i tried to fix it multiple times but it wont let me become a juggernaut after the round has ended
for the juggernaut system, after the round ends, theres a grace period for someone to become a juggernaut, and once someone does, that person becomes the jug and locks everyone else from becoming the juggernaut.
local rs = game.ReplicatedStorage
local maps = rs:WaitForChild(“Maps”)
local res = rs:WaitForChild(“RemoteEvents”)local numMapsVoting = 3
local intermissionTime = 5
local voteTime = 10
local roundTime = 10
local jugGraceTime = 10
local jugTime = 15local plrVotes = {}
function addVote(plr:Player, mapName:string)
plrVotes[plr] = mapName
res:WaitForChild(“Voted”):FireAllClients(plrVotes)
endfunction removePlayerVote(plr:Player)
plrVotes[plr] = nil
res:WaitForChild(“Voted”):FireAllClients(plrVotes)
endfunction loadMap(mapName:string)
local newMap = maps[mapName]:Clone()
newMap.Parent = workspace.Arena.Mainmapreturn newMap
endfunction removeMap(map:Instance)
map:Destroy()
for _, plr in pairs(game.Players:GetPlayers()) do
plr:LoadCharacter()
end
endfunction handleRound()
local plrsAlive = {}
for _, plr in pairs(game.Players:GetPlayers()) doif plr.Character and plr.Character.Humanoid.Health > 0 then table.insert(plrsAlive, plr) plr.Character.Humanoid.Died:Connect(function() table.remove(plrsAlive, table.find(plrsAlive, plr)) end) end
end
script.Time.Value = roundTime
repeat
task.wait(1)
script.Time.Value = script.Time.Value - 1
until script.Time.Value <= 0
script.Time.Value = 0
task.wait(1)
script.RoundEnd.Value = trueend
res:WaitForChild(“Voted”).OnServerEvent:Connect(addVote)
game.Players.PlayerRemoving:Connect(removePlayerVote)
while true do
script.Time.Value = intermissionTime
repeat
task.wait(1)
script.Time.Value = script.Time.Value - 1
until script.Time.Value <= 0
script.Time.Value = 0local mapsToVote = maps:GetChildren()
while #mapsToVote > numMapsVoting do
table.remove(mapsToVote, math.random(1, #mapsToVote))
endplrVotes = {}
res:WaitForChild(“VotingBegun”):FireAllClients(mapsToVote)
script.Time.Value = voteTime
repeat
task.wait(1)
script.Time.Value = script.Time.Value - 1
until script.Time.Value <= 0
script.Time.Value = 0local highestVotedFor = nil
local votes = {}
for i, map in pairs(mapsToVote) do
votes[map.Name] = 0if i == 1 then highestVotedFor = map.Name end
end
for plr, vote in pairs(plrVotes) do
if votes[vote] then votes[vote] += 1 if votes[highestVotedFor] < votes[vote] then highestVotedFor = vote end end
end
res:WaitForChild(“VotingEnded”):FireAllClients()
local newMap = loadMap(highestVotedFor)
handleRound()
repeat
task.wait(1)
until script.RoundEnd.Value == true
script.RoundEnd.Value = false
removeMap(newMap)
end