So I am making a minigame place. The problem is, team minigames don't work for me.
The mainscript causes errors I can't solve! Can you help?
local feed = game.Workspace.GuiText
function minigame()
local maps = game.Lighting.Minigames:GetChildren()
local num = math.random(1, #maps)
local gameChosen = maps[num]:clone()
local spawns = gameChosen.Spawns:GetChildren()
local teamGame = gameChosen.Teams
local raceGame = gameChosen.Race
local gameAn = game.Workspace.GameIsStarting
for int = 30, 1, -1 do
feed.Value = "Intermission: "..int
wait(1)
end
gameAn.Value = true
local mapName = game.Workspace.MapName
mapName.Value = gameChosen.Name
for ready = 10, 1, -1 do
feed.Value = "Get Ready! "..ready
wait(1)
end
gameAn.Value = false
for rsg = 3, 1, -1 do
feed.Value = rsg
wait(1)
end
feed.Value = "Let's go!"
gameChosen.Parent = workspace
for _, player in pairs(game.Players:GetPlayers()) do
local character = player.Character
local targets = player.Targets
targets.Value = 0
local randomSpawn = spawns[math.random(#spawns)] -- EDIT
if character then
character:MoveTo(randomSpawn.Position) -- EDIT
end
end
wait(0.1)
feed.Value = ""
wait(60)
feed.Value = "Good job guys! Game over!"
for _, player in pairs(game.Players:GetPlayers()) do
if teamGame.Value == true then
local winningTeam = gameChosen:FindFirstChild('WinningTeam')
local teamName = player.TeamName
if teamName.Value == winningTeam.Value then
local points = player.Points
local xp = player.XP
points.Value = points.Value + 10
xp.Value = xp.Value + 20
else
local xp = player.XP
xp.Value = xp.Value + 10
end
else
local ingame = player.InGame
if ingame == true then
local points = player.Points
local xp = player.XP
points.Value = points.Value + 10
xp.Value = xp.Value + 20
end
end
wait(3)
mapName.Value = ""
gameChosen:remove()
end
end
while true do
if game.Players.NumPlayers >= 2 then
minigame()
else
wait(0.1)
feed.Value = "Needs 1 more player!"
end
wait()
end
In my output, I get:
07:34:03.949 - Workspace.Script:46: attempt to index local 'winningTeam' (a nil value)
Why is this?

3 comments
YOU'RE THE BEST! THANK YOU!
No problem
Still didin't work d: