• Team Spawns
    0 replies, posted
This is a fairly simple thing but I do not know how to do it. I am trying to make that when player spawns, it looks for its team and then sets the players position from a random taken vector from a table. ///config.lua // Human spawn thing human = {} human.Spawns = { Vector( -8669, 9560, 53 ), Vector( -8765, 8546, 51 ), } // The other team spawn thing test = {} test.Spawns = { Vector( -8669, 9560, 53 ), Vector( -8765, 8546, 51 ), } /// init.lua local ply = FindMetaTable( "Player" ) function GM:PlayerSpawn( ply ) ply:SetupHands() ply:SetModel( "models/player/Group03/male_09.mdl" ) ply:SetTeam( 1 ) -- This is just for the time being. local plyFaction = team.GetName( ply:Team() ) ply:SetPos( plyFaction.Spawns[ math.random( #plyFaction.Spawns) ]) -- Line 33 end /// shared.lua GM.Name = "Test" GM.Author = "hehe" GM.Email = "google@gmail.com" GM.Website = "google.com" team.SetUp( 1, "human", Color( 255, 255, 255 ) ) /// The error [ERROR] gamemodes/testgamemode/gamemode/init.lua:33: attempt to index a string value with bad key ('Spawns' is not part of the string library)   1. error - [C]:-1    2. __index - lua/includes/extensions/string.lua:297     3. unknown - gamemodes/almtech_firefly/gamemode/init.lua:33      4. Spawn - [C]:-1       5. unknown - gamemodes/base/gamemode/player.lua:115 I get it that "plyFaction" returns in a string, how do I make it so it will return as not a string and as shown under this line. /// Example // This will become ply:SetPos( plyFaction.Spawns[ math.random( #plyFaction.Spawns) ]) /////////////////////////////////////////////////////////////////////// // this if the players team is human ply:SetPos( human.Spawns[ math.random( #human.Spawns) ]) // and this if the player is in the other team (test) ply:SetPos( test.Spawns[ math.random( #test.Spawns) ]) Please help.
Sorry, you need to Log In to post a reply to this thread.