Im just getting this error all the time :

Players.Player1.PlayerGui.Menu.Menu.Start Game.Start Game.Click:9: bad argument #1 to 'insert' (table expected, got nil)

here is the script

function EndMenu()
wait()
local frame = script.Parent.Parent.Parent
local play = script.Parent

for i , v in pairs(game.Players:GetPlayers()) do
	wait(0.5)
if v then
	table.insert(_G.gameplayers,v.Name)
	end
frame.Visible = false 
end
end

script.Parent.MouseButton1Down:connect(EndMenu)

I want that if u click the Textbutton you willö be added to the Table _G.gameplayers

2 comments

1

Few questions: Is this a local or server script? Is _G.gameplayers defined? If _G.gameplayers is defined what script is it in, a local or server script?

0

Why do you check if the player exists when the GetPlayers functions returns players that are in the game?