(GAMEMODE) For loop with player models table error...

Hello, Recently I started with making a gamemode for Garry’s Mod. I made a for loop with a table for my player models. I get an error, but I dont know how to fix it. Can someone please help me?

Error: [gamemodes[gamemode_name_unknown]\gamemode\shared.lua:35] attempt to index global ‘ply’ (a nil value)

For loop with table:

PModel = { { “models/player/Group01/Female_01.mdl”,
“models/player/Group01/Male_09.mdl” }, { “models/player/police.mdl” },
{ “models/player/combine_soldier_prisonguard.mdl” }, { “models/player/breen.mdl” },
{ “models/player/Group03/Female_01.mdl”,
“models/player/Group03/Male_09.mdl” },
{ “models/player/gman_high.mdl” },
{ “models/player/monk.mdl” },
{ “models/player/kleiner.mdl” } }

for k, v in pairs( PModel ) do
if ply:Team() == k then – error line
ply:SetModel (v [math.random (1, table.Count(v) ) ] )

Need to find player by a parameter of a function or finding them by other source such as name and stuff.

Such as:

	function GM:PlayerSetModel( ply )
		//Your code

Have a look here see what you can find that would suit your need.

Thank you. :smiley:

Next time use [lua.] ^^ [/lua] I like cider, tell me when the server is up