I need help with my script I was writing. I was fixing my script and once I finished I saw a variable and a for loop underlined. I don’t know why at all
Entire script
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local Teams = game:GetService("Teams")
local Cooldown = wait(3)
local Status = ReplicatedStorage.Status
local VotingSystem = game.Workspace.Voting
local Choices = VotingSystem:GetChildren()
local Maps = ReplicatedStorage.Maps:GetChildren()
local Intermission = 15
local LobbyTeam = Teams["Lobby"]
local RedTeam = Teams["Killer"]
local BlueTeam = Teams["Runner"]
local RedTeamColor = RedTeam.TeamColor
local BlueTeamColor = BlueTeam.TeamColor
local RedTeamCount
local BlueTeamCount
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 Index, 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 = RandomMap.Image.Value
RandomMap.CanBeVoted.Value = true
else
Name.Text = RandomMap.Name
Picture.Image = RandomMap.Image.Value
RandomMap.CanBeVoted.Value = true
end
end
ReplicatedStorage.InRound.Changed:Connect(function()
if ReplicatedStorage.InRound.Value == false then
MapClone:Destroy()
for Index, Map in pairs(Maps) do
Map.CanBeVoted.Value = false
end
for Index, 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 = RandomMap.Image.Value
RandomMap.CanBeVoted.Value = true
else
Name.Text = RandomMap.Name
Picture.Image = 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 Index, Map in pairs(Maps) do
if ChosenMap == Map.Name then
MapClone = Map.Clone()
MapClone.Parent = game.Workspace
end
end
Cooldown
for Index, Choice in pairs(Choices) do
Choice.label.SurfaceGui.TextLabel.Text = " "
Choice.Image.SurfaceGui.ImageLabel.Image = " "
Choice.button.Votes:ClearAllChildren()
ReplicatedStorage.VoteReset:FireAllClients(Choice.button)
end
local BlueTeamCount = {}
local RedTeamCount = {}
local Contestants = {}
for Index, Player in pairs(Players:GetChildren()) do
local Character = Player.Character
local RootPart = Character:WaitForChild("HumanoidRootPart")
local NameGUI = Character.Head:FindFirstChild("NameGUI")
-- Spawns
local RedSpawns = MapClone.RedSpawns:GetChildren()
local BlueSpawns = MapClone.BlueSpawns:GetChildren()
local RandomRedSpawn = RedSpawns[math.random(1,#RedSpawns)]
local RandomBlueSpawn = BlueSpawns[math.random(1,#BlueSpawns)]
if #RedTeamCount == 1 then
Player.Team = BlueTeam
RootPart.CFrame = RandomBlueSpawn.CFrame + Vector3.new(math.random(1,3),math.random(1,3),math.random(1,3))
Player.CameraMode = "Classic"
Player.CameraMaxZoomDistance = 9
table.insert(BlueTeamCount, Player.Name)
if NameGUI then
NameGUI.Name.TextColor3 = BlueTeamColor
end
print(Player.Name .. "Inside: ".. Player.Team.Name)
elseif #RedTeamCount == 0 then
Player.Team = redTeam
Player.CameraMode = "LockFirstPerson"
Player.CameraMaxZoomDistance = 0.5
RootPart.CFrame = RandomRedSpawn.CFrame + Vector3.new(math.random(1,3),math.random(1,3),math.random(1,3))
table.insert(RedTeamCount, Player.Name)
if NameGUI then
NameGUI.Name.TextColor3 = RedTeamColor
end
print(Player.Name .. "Inside: ".. Player.Team.Name)
else
while true do
wait(2)
for Index, Player in pairs(Players:GetChildren()) do
if Player and Player.Character then
local Human = Player.Character:WaitForChild("Humanoid")
if Human and Human.Health > 0 then
table.insert(Contestants,Player)
end
end
end
if #Contestants >= 2 then
break
else
print("Waiting For Players")
end
end
local Killer = Contestants[math.random(1,#Contestants)
local KillerTwo = Contestants[math.random(1,#Contestants)
for Index, Player in pairs(Players:GetChildren()) do
if Player == Killer then
Player.Team = RedTeam
RootPart.CFrame = RandomRedSpawn.CFrame + Vector3.new(math.random(1,3), math.random(1,3), math.random(1,3))
Player.CameraMode = "LockFirstPerson"
Player.CameraMaxZoomDistance = 9
table.insert(RedTeamCount, Player.Name)
if NameGUI then
NameGUI.Name.TextColor3 = RedTeamColor
end
print(Player.Name.." Inside: "..Player.Team.Name)
elseif Player ~= Killer then
Player.Team = BlueTeam
Player.CameraMode = "Classic"
Player.CameraMaxZoomDistance = 9
RootPart.CFrame = RandomBlueSpawn.CFrame + Vector3.new(math.random(1,3),math.random(1,3),math.random(1,3))
table.insert(BlueTeamCount, Player.Name)
if NameGUI then
NameGUI.Name.TextColor3 = BlueTeam
end
print(Player.Name.." Inside: "..Player.Team.Name)
end
end
if #Contestants >= 6 then
if Player == Killer2 then
Player.Team = RedTeam
RootPart.CFrame = RandomRedSpawn.CFrame + Vector3.new(math.random(1,3), math.random(1,3), math.random(1,3))
Player.CameraMode = "LockFirstPerson"
Player.CameraMaxZoomDistance = 9
table.insert(RedTeamCount, Player.Name)
if NameGUI then
NameGUI.Name.TextColor3 = RedTeamColor
end
print(Player.Name.." Inside: "..Player.Team.Name)
elseif Player ~= Killer2 then
Player.Team = BlueTeam
Player.CameraMode = "Classic"
Player.CameraMaxZoomDistance = 9
RootPart.CFrame = RandomBlueSpawn.CFrame + Vector3.new(math.random(1,3),math.random(1,3),math.random(1,3))
table.insert(BlueTeamCount, Player.Name)
if NameGUI then
NameGUI.Name.TextColor3 = BlueTeam
end
end
end
end
Character:WaitForChild("Humanoid").Died:Connect(function()
Player.Team = LobbyTeam
Player.CameraMode = "Classic"
Player.CameraMaxZoomDistance = 9
end)
end
end
end)