hi, I’m making a MiniGames game, all work but at the part of the game, all the rounds are only 0 seconds IDK why It don’t error anything and all works fine. My script:
local MiniGames = game.ReplicatedStorage.Minigames
local Text = game.ReplicatedStorage.Mains.Text
local MinPlayers = 2
local LobbyTime = 15
local MapData = {
['LavaRun'] = {'OneTeam',150,'Spawns',50,function()
for _,Character in ipairs(workspace.InGame:GetChildren()) do
local hum = Character:FindFirstChild('Humanoid')
if hum then
hum.WalkSpeed = 50
end
end
end}
}
while wait() do
if #game.Players:GetPlayers() >= MinPlayers then
local GameEnded = true
for i = LobbyTime,1,-1 do
if i >= 1 then
wait(1)
Text.Value = 'Game Starts in '..tostring(i)
else
break
end
end
local m = math.random(1,#MiniGames:GetChildren())
local ChosenMap = MiniGames:GetChildren()[m].Name
local Team1,Team2 = nil,nil
local Main
for Name,Table in next,MapData do
if Name == ChosenMap then
Main = Table
end
end
for _,Player in ipairs(game.Players:GetChildren()) do
if not Player.AFK.Value == true then
Player.Character.Parent = workspace.InGame
end
end
wait(0.1)
local Teams = Main[1]
local Time = Main[2]
local MoneyReward
local Event
if Teams == 'OneTeam' then
Team1 = Main[3]
Event = Main[5]
MoneyReward = Main[4]
elseif Teams == 'TwoTeams' then
Team1 = Main[3]
Team2 = Main[4]
Event = Main[6]
MoneyReward = Main[5]
end
wait(0.1)
Event()
MiniGames[ChosenMap]:Clone().Parent = workspace.MiniGame
if Team1 ~= nil and Team2 ~= nil then
for _, Player in ipairs(game.Players:GetPlayers()) do
local Char = Player.Character
Char.Parent = workspace.InGame
local m = math.random(1,2)
if m == 1 then
local c = Player.Character
if c and c.Head then
local H = c.Head
local m2 = math.random(1,#workspace.MiniGame[ChosenMap][Team1]:GetChildren())
local H2 = workspace.MiniGame[ChosenMap][Team2]:GetChildren()[m2]
H.CFrame = H2.CFrame
end
elseif m == 2 then
local c = Player.Character
if c and c.Head then
local H = c.Head
local m3 = math.random(1,#workspace.MiniGame[ChosenMap][Team2]:GetChildren())
local H3 = workspace.MiniGame[ChosenMap][Team2]:GetChildren()[m3]
H.CFrame = H3.CFrame
end
end
end
elseif Team1 ~= nil and Team2 == nil then
for _, Player in ipairs(game.Players:GetPlayers()) do
local Char = Player.Character
Char.Parent = workspace.InGame
local c = Player.Character
if c and c.Head then
local H = c.Head
local m2 = math.random(1,#workspace.MiniGame[ChosenMap][Team1]:GetChildren())
local H2 = workspace.MiniGame[ChosenMap][Team1]:GetChildren()[m2]
H.CFrame = H2.CFrame
end
end
end
for i = Time,1,-1 do
if not i == Time then
wait(1)
Text.Value = ' Game Ends in '..tostring(i)
else
GameEnded = true
end
end
if #workspace.InGame:GetChildren() == 0 then
Text.Value = 'Nobody wins!'
GameEnded = true
elseif #workspace.InGame:GetChildren() == 1 then
GameEnded = true
local winner = workspace.InGame:GetChildren()[1].Name
local Pwinner = game.Players[winner]
game.ReplicatedStorage.Events.IncrementMoney:Fire(Pwinner,tonumber(MoneyReward))
Text.Value = winner..' Has Won!'
end
repeat wait() until GameEnded == true
repeat
wait(1)
if GameEnded == true then
for _, Character in ipairs(workspace.InGame:GetChildren()) do
Character.Head:Destroy()
end
workspace.MiniGame[ChosenMap]:Destroy()
if GameEnded == true then
break
end
end
until true == false
else
Text.Value = 'U need to be at least '..tostring(MinPlayers)..' Players!'
end
end