it keeps coming up with this error: 10:45:33.739 - ServerScriptService.ModuleScript:13: attempt to call a nil value
This is inside a module script and they say the problem is in line 13
local players = {}
local floor = workspace.Floor
local frame = floor.BillboardGui.Frame
local timet = frame.TimeT
local p1
local p2
local t1 = frame.Player1
local t2 = frame.Player2
local function setPlayers()
if(p1 == nil)then
for i,v in pairs(players:GetChildren())do
if(v.TeamColor == BrickColor.new("Really red"))then
p1 = v
end
end
setPlayers()
elseif(p1 and p2 == nil)then
for i,v in pairs(players:GetChildren())do
if(v.TeamColor == BrickColor.new("Really blue"))then
p2 = v
end
end
end
end
local function updatePlayers()
for i,v in pairs(game.Players:GetChildren())do
table.insert(players, v)
end
setPlayers()
end
return function()
local function core()
if not(#players == 1)then
updatePlayers()
t1.Text = p1.Name
t2.Text = p2.Name
frame.Parent.Enabled = true
for i=10, 0, -1 do
local stringConversion = tostring(i)
timet = stringConversion
wait(1)
end
timet.Text = "10"
frame.Parent.Enabled = false
p1.Character.HumanoidRootPart.Position = Vector3.new(math.random(-15.5, 15.5), 21.5, math.random(-15.5, 15.5))
p2.Character.HumanoidRootPart.Position = Vector3.new(math.random(-15.5, 15.5), 21.5, math.random(-15.5, 15.5))
p1.Character.Died:Connect(function()
table.remove(players, p2)
p1.Character.Humanoid.Health = 0
p2.Character.Humanoid.Health = 0
core()
end)
p2.Character.Died:Connect(function()
table.remove(players, p1)
p2.Character.Humanoid.Health = 0
p1.Character.Humanoid.Health = 0
core()
end)
else
print("done lol")
end
end
core()
end

1 comment
The table players is empty, did you mean game.Players:GetChildren()