My round system for my game has worked perfectly fine for the past weeks but just this morning all of the sudden while doing a play test the game would keep looping over and saying that “Everyone has died”.
Checked the console for any logs or error but there was nothing to be found. Even when searching up the round systems in filter.
Even went has far as to go back to the original version and copy the scripts to put them into the latest (just in case I might have deleted a line or something while working on it).
I really need some clarification on this or my game is
Here are all the scripts and locations
ServerScriptServer - VotingSystem
local rep = game:GetService("ReplicatedStorage")
local votingSystem = game.Workspace.Voting
local status = rep.Status
local choices = votingSystem:GetChildren()
local maps = rep.Maps:GetChildren()
local intermission = 10
local isAnOption
local randomMap
local chosenMap
local mapClone
local function PickRandomMap ()
local randomNumber = math.random(1, #maps)
randomMap = maps[randomNumber]
return randomMap.CanBeVoted
end
for i, choice in pairs(choices) do
local name = choice.label.SurfaceGui.TextLabel
local picture = choice.Image.SurfaceGui.ImageLabel
isAnOption = PickRandomMap()
if isAnOption.Value == true then
repeat
isAnOption = PickRandomMap()
until
isAnOption.Value == false
name.Text = randomMap.Name
picture.Image = "rbxassetid://" ..randomMap.Image.Value
randomMap.CanBeVoted.Value = true
else
name.Text = randomMap.Name
picture.Image = "rbxassetid://" .. randomMap.Image.Value
randomMap.CanBeVoted.Value = true
end
end
rep.InRound.Changed:Connect(function()
if rep.InRound.Value == false then
mapClone:Destroy()
for i, map in pairs(maps) do
map.CanBeVoted.Value = false
end
for i, choice in pairs(choices) do
local name = choice.label.SurfaceGui.TextLabel
local picture = choice.Image.SurfaceGui.ImageLabel
isAnOption = PickRandomMap()
if isAnOption.Value == true then
repeat
isAnOption = PickRandomMap()
until
isAnOption.Value == false
name.Text = randomMap.Name
picture.Image = "rbxassetid://" .. randomMap.Image.Value
randomMap.CanBeVoted.Value = true
else
name.Text = randomMap.Name
picture.Image = "rbxassetid://" ..randomMap.Image.Value
randomMap.CanBeVoted.Value = true
end
end
else
local Choice1Votes = #votingSystem.Choice1.button.Votes:GetChildren()
local Choice2Votes = #votingSystem.Choice2.button.Votes:GetChildren()
local Choice3Votes = #votingSystem.Choice3.button.Votes:GetChildren()
if Choice1Votes >= Choice2Votes and Choice1Votes >= Choice3Votes then
chosenMap = votingSystem.Choice1.label.SurfaceGui.TextLabel.Text
elseif Choice2Votes >= Choice1Votes and Choice2Votes >= Choice3Votes then
chosenMap = votingSystem.Choice2.label.SurfaceGui.TextLabel.Text
else
chosenMap = votingSystem.Choice3.label.SurfaceGui.TextLabel.Text
end
status.Value = "The Chosen map is: ".. chosenMap
for i, map in pairs(maps) do
if chosenMap == map.Name then
mapClone = map:Clone()
mapClone.Parent = game.Workspace
end
end
wait(3)
for i, choice in pairs(choices) do
choice.label.SurfaceGui.TextLabel.Text = " "
choice.Image.SurfaceGui.ImageLabel.Image = " "
choice.button.Votes:ClearAllChildren()
rep.VoteReset:FireAllClients(choice.button)
end
local spawns = mapClone.Spawns:GetChildren()
for i, plr in pairs(game.Players:GetChildren()) do
local char = plr.Character
local hum = char:WaitForChild("Humanoid")
local humanRoot = char:WaitForChild("HumanoidRootPart")
plr.Team = game.Teams.Playing
humanRoot.CFrame = spawns[math.random(1, #spawns)].CFrame + Vector3.new(math.random(1,4),math.random(1,4),math.random(1,4))
hum.Died:Connect(function()
plr.Team = game.Teams.Lobby
end)
end
end
end)
ServerScriptService - MainRoundScript
local intermission = 10
local roundLength = 15
local inRound = game.ReplicatedStorage.InRound
local staus = game.ReplicatedStorage.Status
local playersRequired = 1
inRound.Changed:Connect(function()
if inRound.Value == false then
for i, plr in pairs(game.Players:GetChildren()) do
local char = plr.Character
local humanRoot = char:WaitForChild("HumanoidRootPart")
humanRoot.CFrame = game.Workspace.lobbySpawn.CFrame
end
end
end)
local function round()
while true do
repeat
wait(1)
staus.Value = tostring(playersRequired) .. " players are needed to start a game!"
until #game.Players:GetChildren() >= playersRequired
inRound.Value = false
for i = intermission, 0, -1 do
staus.Value = "Game will start in "..i.." seconds"
wait(1)
end
inRound.Value = true
wait(3)
for i = roundLength, 0, -1 do
wait(1)
staus.Value = "Game will end in "..i.." seconds"
local playing = {}
for i, plr in pairs(game.Players:GetChildren()) do
if plr.Team.Name == "Playing" then
table.insert(playing, plr.Name)
print("inserted player")
end
end
if #playing == 0 then
staus.Value = "Everyone Has Died"
wait(3)
break
end
end
end
end
spawn(round)
StarterGui - Voted
local rep = game:GetService("ReplicatedStorage")
local inRound = rep:WaitForChild("InRound")
local votingSystem = game.Workspace:WaitForChild("Voting")
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.Character.CharacterAdded:Wait()
local db = false
local NonVotedColour = BrickColor.new("Fossil")
local votedColour = BrickColor.new("Bright green")
task.wait(1)
local choices = votingSystem:GetChildren()
print(#choices)
for i,v in pairs(choices) do
print(v.Name)
v:WaitForChild("button").Touched:Connect(function(h)
print("t")
if h:IsDescendantOf(char) and not db then
db = true
for i,v2 in pairs(choices) do
if v2 ~= v then
v2.button.BrickColor = NonVotedColour
else
v2.button.BrickColor = votedColour
end
end
wait(.1)
db = false
end
end)
end
rep.VoteReset.OnClientEvent:Connect(function(button)
button.BrickColor = BrickColor.new("Fossil")
end)
Here are some more details just because i need you to have as much background as possible to as how this works.
These are the bools and vars inside of the maps folder in replicated storage.
–
Here are some of the extra remote events and vars located inside the replicated storage.
–
And that’s all, hopefully you can figure this out. Goodluck too!