The function does not even start. Also did I forget to mention that this is in a while loop? Sorry about that
. Here is the full code:
local RS = game.ReplicatedStorage
local SS = game.ServerStorage
local Maps = SS:WaitForChild("Maps")
local Status = RS:WaitForChild("Status")
local intermissionLength = 15
local questions = {
"Name an animal",
"Name an US President"
}
local answers = {
"dog",
"cat",
"mockingjay",
"goldfish",
"george washington",
"barack obama",
"abraham lincoln"
}
while true do
--Status.Value = "Waiting for enough players! (1/2)"
--repeat wait() until game.Players.NumPlayers >=2
Status.Value = "Intermission:"
task.wait(3)
Status.Value = "15"
for i=intermissionLength,0,-1 do
wait(1)
local new = tonumber(Status.Value)-1
Status.Value = tostring(new)
end
--END OF INTERMISSION
local plrs = {}
for i,player in pairs(game.Players:GetPlayers()) do
if player then
table.insert(plrs,player) --add plr
end
end
local AvailableMaps = Maps:GetChildren()
local ChosenMap = AvailableMaps[math.random(1,#AvailableMaps)]
Status.Value = ChosenMap.Name.. " chosen"
wait(2)
Status.Value = "Game starting!"
wait(2)
local ClonedMap = ChosenMap:Clone()
--ClonedMap:SetPrimaryPartCFrame(CFrame.new(490.263, 78.957, -4.343))
if ClonedMap.Name == "Radioactive" then
ClonedMap:PivotTo(CFrame.new(490.263, 79.457, -4.343) * CFrame.Angles(0, 0, math.pi)) -- may need to use X axis instead)
elseif ClonedMap.Name == "Construction" then
ClonedMap:PivotTo(CFrame.new(490.263, 35.957, -4.343))
end
ClonedMap.Parent = workspace
local SpawnPoints = ChosenMap:FindFirstChild("SpawnPoints")
if not SpawnPoints then
warn("No spawnpoints found")
end
--END OF CHOOSING MAP
local AvailableSpawns = SpawnPoints:GetChildren()
for i,player in pairs(plrs) do
if player then
local char = player.Character
if char then
char:FindFirstChild("HumanoidRootPart").CFrame = AvailableSpawns[1].CFrame + Vector3.new(0,2,0)
table.remove(AvailableSpawns,1)
local GameTag = Instance.new("BoolValue")
GameTag.Name = "GameTag"
GameTag.Parent = char
else
if not player then
table.remove(plrs,i)
end
end
end
end
--END OF TELEPORTING PLAYERS
Status.Value = "Get ready to play!"
for i,player in pairs(plrs) do
if player then
local character = player.Character
if not character then
print("Player left the game")
table.remove(plrs,i)
elseif character:FindFirstChild("GameTag") then
print(player.Name.. " is still in the game!")
else
table.remove(plrs,i)
end
else table.remove(plrs,i)
print(player.Name.. " has been removed")
end
end
--END OF PLAYER DIED/REMOVED/LEFT
game.ReplicatedStorage.SendAnswer.OnServerEvent:Connect(function(player,answer)
if answer == table.find(answers,answer) then
local length = #answer
string.lower(answer)
for i = 1,length do
local step = Instance.new("Part")
step.Parent = ClonedMap
step.Color = Color3.new(0.901961, 1, 0.576471)
step.Name = "testingStep"
step.Size = Vector3.new(5,1,5)
step.CFrame = player.Character:FindFirstChild("HumanoidRootPart").CFrame - Vector3.new(0,1,0)
print(step.Parent)
end
end
end)
repeat
game.ReplicatedStorage.SafeAnswer:FireAllClients()
Status.Value = questions[math.random(1,#questions)]
wait(10)
ClonedMap.Lava.Size += Vector3.new(0,10,0)
until #plrs == 0
if #plrs == 1 then
if plrs[1].Character:FindFirstChild("GameTag") then
Status.Value = "The winner is: " ..plrs[1].Name
plrs[1].leaderstats.Wins.Value += 1
end
elseif #plrs == 0 then
Status.Value = "Nobody won!"
end
print("End of game")
task.wait(2)
for i,player in pairs(game.Players:GetPlayers()) do
local charac = player.Character
if not charac then
print("Player does not have character!")
elseif charac then
if charac:FindFirstChild("GameTag") then
charac.GameTag:Destroy()
player:LoadCharacter()
end
end
end
ClonedMap:Destroy()
Status.Value = "Game ended!"
task.wait(15)
--END OF GAME ENDING
end
I changed up the function of the answer a little bit so its all lowercase if the player gets it correct but has different capitilization.
The function is a bit at the end of the script, like 2/3’s
Should I do this in a different script? However that would break all local variables I have with this script making it nearly impossible for me to do it.