Output error: ServerScriptService.MainScript:45: attempt to call a nil value
As you can see from the title, I am trying to get the amount of children from a table. At first I tried to see if the table name itself was <= to a number, then I got an error for that. I tried searching it up, and I tried two different things, they were basicly the same thing but the second one used variables. I tried both and got an error, both had the exact same one. The script I am showing was me trying to use the second one. I just need help with figuring out how many children a table has. Tell me if I'm doing something wrong. The line where the error took me is on line 46, I left in the other code just in case it has something to do with it.
-- MAKING TABLE HERE
local PlayerTable = {}
local Platform = game.Workspace.Platform
while true do
-- NOTHING IMPORTANT HAPPENING YET
Platform.Touched:Connect(function(hit)
local Character = hit.Parent
local Player = game.Players:GetPlayerFromCharacter(Character)
local GameTag = Instance.new("BoolValue")
GameTag.Parent = Player
GameTag.Name = "GameTag"
GameTag.Parent = false
local InRound = false
for _, player in pairs do
if player == player then
InRound = true
end
end
if not InRound then
table.insert(PlayerTable, Player.GameTag)
end
end)
Platform.TouchEnded:Connect(function(hit)
local Character = hit.Parent
local Player = game.Players:GetPlayerFromCharacter(Character)
local InRound = false
table.remove(PlayerTable, Player.GameTag)
end)
local IntermissionNumber = 15
local IntermissionString = "Intermission for "
local IntermissionString2 = " more seconds!"
-- IMPORTANT STUFF HERE IN THE WHILE LOOP
while true do
local Status = game.ServerStorage.Status
-- The error happened below this comment
local PTChildren = PlayerTable:GetChildren()
local PTCount = #PTChildren
if PTCount <= 1 then
Status.Value = "Not Enough Players On Platform to Start Game!"
end
Status.Value = IntermissionString..IntermissionNumber..IntermissionString2
wait(1)
IntermissionNumber = IntermissionNumber - 1
if IntermissionNumber <= 0 then
Status.Value = "Game Starting"
wait(1)
break
end
if PlayerTable <= 1 then
end
end
end

1 comment
I dont understand what you mean by #NAMEOFTALE