Hey there all!
So, I’ve been working on a round system for a while now but there’s a problem. Whenever the intermission ends, it doesn’t perform the round part. Instead it instantly switches back to intermission again. I’d really appreciate any help since I’ve been struggling with this problem for a week or 2. Thanks!
Code
_Round (Module)
--// Module Variables
local round = {}
--// ReplicatedStorage Variables
--[[
:WaitForChild("Object")
]]
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Values = ReplicatedStorage:WaitForChild("Values")
local Status = Values:WaitForChild("Status")
local Timer = Values:WaitForChild("Timer")
local RoundInProgress = Values:WaitForChild("RoundInProgress")
--// Main
function round:Countdown(status : string, IsRoundInProgress : boolean, IsCountdownEnabled : boolean, Length : number)
Status.Value = status
RoundInProgress.Value = IsRoundInProgress
if IsCountdownEnabled then
local CountdownOver = Instance.new("BindableEvent")
Timer.Value = Length
local function toMS(s)
return ("%02i:%02i"):format(s / 60 % 60, s % 60)
end
for timer = Length, 0, -1 do
Timer.Value = toMS(timer)
task.wait(1)
print(Timer.Value)
end
CountdownOver:Fire()
return {CountdownOver.Event}
end
end
return round
--\\
Server
--// Services
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
--// Module Requirements
local Modules = ReplicatedStorage:WaitForChild("Modules")
local _Player = require(Modules:WaitForChild("_Player"))
local _Round = require(Modules:WaitForChild("_Round"))
local Gamemodes = Modules:WaitForChild("Gamemodes")
local Deathmatch = require(Gamemodes:WaitForChild("Deathmatch"))
local _Weapon = require(Modules:WaitForChild("_Weapon"))
--// ReplicatedStorage Variables
local Values = ReplicatedStorage:WaitForChild("Values")
local Status = Values:WaitForChild("Status")
local RoundInProgress = Values:WaitForChild("RoundInProgress")
local Remotes = ReplicatedStorage:WaitForChild("Remotes")
local RemoteEvents = Remotes:WaitForChild("Events")
local ToggleMenuForAllPlayersRE = RemoteEvents:WaitForChild("ToggleMenuForAllPlayersRE")
local PlayerContainer = ReplicatedStorage:WaitForChild("PlayerContainer")
--// Other Variables
local Spawns = game.Workspace.SpawnBox.Spawns:GetChildren()
--// Main
while task.wait(1) do
local Intermission = nil
Intermission = _Round:Countdown("Intermission", false, true, 10)
if Intermission ~= nil then
Intermission[1]:Connect(function()
Status.Value = "Round"
RoundInProgress.Value = true
end)
end
if (Status.Value == "Round" and RoundInProgress.Value == true) then
PlayerContainer.ChildAdded:Connect(function(child)
if Players:FindFirstChild(child.Name) then
local FoundPlayer = Players:FindFirstChild(child.Name)
local FoundCharacter = FoundPlayer.Character or FoundPlayer.CharacterAdded:Wait()
local NonSaveInfo = FoundPlayer:WaitForChild("NonSaveInfo")
local Kills = NonSaveInfo:WaitForChild("Kills")
Kills.Changed:Connect(function(x)
print(tostring(x))
if x == 20 then
print(string.format(("%s has won!"), FoundPlayer.Name))
end
end)
end
end)
end
end