my problem is this: while solo testing the game (meaning i’m not sure if this’ll change when dealing with multiple players) when i reach the end of the maze and touch the desired part, it’s supposed to let me through into an elevator. this all works. however there’s an issue where it skips the rest of my code once my player is added to the winners table. i’ve tested before i updated this script and each time a winner was updated the rest of the code ran perfectly.
here is the main server script:
-- Services --
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local StarterGui = game:GetService("StarterGui")
-- Modules --
local RoundModule = require(script.RoundModule)
-- Guis --
local StatusGui = StarterGui:WaitForChild("StatusGui")
-- Variables --
local IntermissionTime = 15
local VotingTime = 10
local RoundTime
local AbleToWin = true
local StatusValue = ReplicatedStorage:WaitForChild("Values"):FindFirstChild("StatusValue")
-- Folders --
local Minigames = ReplicatedStorage:WaitForChild("Minigames"):GetChildren()
local CurrentMinigames = game:GetService("Workspace"):WaitForChild("CurrentMinigames")
local InGameFolder = game:GetService("Workspace"):WaitForChild("InGameFolder")
-- Tables --
local WinnersTable = {}
-- Script --
while true do
IntermissionTime = 15
repeat
IntermissionTime -= 1
StatusValue.Value = "Intermission: "..IntermissionTime
task.wait(1)
until IntermissionTime == 0
print("Starting round.")
StatusValue.Value = "Round starting..."
task.wait(1)
StatusValue.Value = "Round starting.."
task.wait(1)
StatusValue.Value = "Round starting."
task.wait(1)
StatusValue.Value = "Round starting"
local RandomMinigame = math.random(1, #Minigames)
local ChosenMinigame = Minigames[RandomMinigame]:Clone()
ChosenMinigame.Parent = CurrentMinigames
local Players = game:GetService("Players"):GetChildren()
for i = 1, #Players do
if Players[i].Character ~= nil then
local RandomTeleportPoint = math.random(1, #ChosenMinigame:WaitForChild("TeleportPoints"):GetChildren())
Players[i].Character.Head.CFrame = ChosenMinigame.TeleportPoints[RandomTeleportPoint].CFrame
Players[i].Character.Parent = InGameFolder
end
end
AbleToWin = true
if ChosenMinigame:FindFirstChild("ObstacleRace") then
-- Set up Minigame.
RoundTime = 10
-- Minigame Over.
ChosenMinigame:WaitForChild("EndPoint").Touched:Connect(function(Hit)
if Hit.Parent:FindFirstChild("Humanoid") then
if AbleToWin == true then
AbleToWin = false
local Winner = game:GetService("Players"):GetPlayerFromCharacter(Hit.Parent)
table.insert(WinnersTable, Winner.Name)
print("Touched.")
end
end
end)
end
if ChosenMinigame:FindFirstChild("Maze") then
-- Set up Minigame.
RoundTime = 60
RoundModule.LockFirstPerson()
game:GetService("Lighting").ClockTime = 0
-- Minigame Over.
ChosenMinigame:WaitForChild("EndPoint").Touched:Connect(function(Hit)
if Hit.Parent:FindFirstChild("Humanoid") then
if AbleToWin == true then
local Winner = game:GetService("Players"):GetPlayerFromCharacter(Hit.Parent)
table.insert(WinnersTable, Winner.Name)
ChosenMinigame.EndPoint.CanTouch = false
ChosenMinigame.EndPoint.CanCollide = false
print("Touched.")
script.Disabled = true
task.wait(1)
ChosenMinigame.EndPoint.CanTouch = true
ChosenMinigame.EndPoint.CanCollide = true
script.Disabled = false
end
end
end)
end
repeat
RoundTime -= 1
StatusValue.Value = "Round over in: "..RoundTime
task.wait(1)
until RoundTime == 0 or AbleToWin == false or #InGameFolder:GetChildren() == 0
AbleToWin = false
RoundModule.UnlockFirstPerson()
game:GetService("Lighting").ClockTime = 14.5
StatusValue.Value = "Round over!"
task.wait(3)
StatusValue.Value = "Winners: "..table.concat(WinnersTable)
RoundModule.NewRound()
WinnersTable = {}
task.wait(3)
end
and here is the module script:
local RoundModule = {}
function RoundModule.NewRound()
for i, Player in pairs(game:GetService("Players"):GetPlayers()) do
Player:LoadCharacter()
print("Reset round.")
local CurrentMinigames = game:GetService("Workspace").CurrentMinigames
for i, Minigame in pairs(CurrentMinigames:GetChildren()) do
if Minigame:IsA("Model") then
Minigame:Destroy()
end
end
end
end
function RoundModule.LockFirstPerson()
local InGameFolder = game:GetService("Workspace").InGameFolder
for i, Player in pairs(game:GetService("Players"):GetPlayers(InGameFolder:GetChildren())) do
Player.CameraMode = Enum.CameraMode.LockFirstPerson
end
end
function RoundModule.UnlockFirstPerson()
local InGameFolder = game:GetService("Workspace").InGameFolder
for i, Player in pairs(game:GetService("Players"):GetPlayers(InGameFolder:GetChildren())) do
Player.CameraMode = Enum.CameraMode.Classic
end
end
return RoundModule
any help would be appreciated.
i do have a suspicion that messing around with disabling the script for a very sloppy cooldown might have something to do with it.