Need help fixing my Gamemode.

Hi there, I am making my first Gamemode and I got a little problem that I can’t find the answer myself.

I got a few questions about Lua and Gmod. I hope people around can help me out.

Right now I have made the base for my Gamemode.

the system chose randomly which team you go and give you an equipment depending on your player model.

My gamemode is inspirated from Zombies survival maps and Role Playing. The main goal will be about surviving in different maps the hordes of zombies.
I plan to add Zombies NPC.

First there is 2 team. The survivor and the Infected. When a survivor die there is a little chance he get infected and become a zombie unless a zombie killed him ( 100% chance ) Dead players will spawn in the Lobby as a ‘third team’ Spectators.
The lobby will contains small shops and stuff that can be commonly seen in RP maps. When a player kill a zombie or the opposite they earn EXP so they can buy more specific Items.
One round has to length about 30 minutes and longer you survive, more XP/cash you get from kills.

I am not done thinking about everything. but I guess you have an idea.

I am still a beginner and this project will give me more experiences.

I will update the thread with new questions as I go. Thank you for any help.

Right Now I am tying to find information about changing NPC’s damage, health and speed.
Also How to make a type of NPC ( Lets say Zombies ) Friendly with the one who are in the Infected team but deadly for the Survivor team?

I also Need help and tips about my current Init.lua file bellow.

Temporary Download.
Pre Alpha 0.37



AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")

include('shared.lua')

// Serverside only stuff goes here

/*---------------------------------------------------------
   Name: gamemode:PlayerLoadout()
   Desc: Give the player the default spawning weapons/ammo
---------------------------------------------------------*/


////////// DEFAULT SETTING /////////
/*-------------------------------------------------------------
	Enter Default Variable here
*/-------------------------------------------------------------


///////// Characters Classes /////////
/*------------------WIP------------------------
############## Comming Soon! ##################
###############################################
## TODO:      Adding different player model  ##
## depending on the Class the player take.   ##
##  The class will give different advantage  ##
## To the player to offer a better gameplay  ##
##   such as Speed, Health, Weapons, ect...  ##
## They will also influence a lot on the     ##
## player's progression                      ##
###############################################
*/---------------------------------------------

/*
function T2C2(ply)
end
*/

/////////ON MAP SPAWN/////////////

function GM:PlayerInitialSpawn(ply)

	PrintMessage(HUD_PRINTTALK, "Welcome" ..ply:Name().. " your SteamID is "..ply:SteamID()..".")
		PrintMessage(HUD_PRINTTALK, "You are actually in the Team : "..ply:Team()..".")
end

///////////// ON PLAYER SPAWN //////////////
function GM:PlayerSpawn(ply)
	local batt = math.random(1, 2)
		if batt == 2 then 
			ply:SetTeam(2)
		elseif batt == 1 then 
			ply:SetTeam(1)
		end
if ply:Team() == 1 then
PrintMessage(HUD_PRINTTALK, "You are actually in the Team : "..ply:Team()..".")
local T1C1 = math.random(1, 9)				
			
	if T1C1 == 1 then 
		ply:SetModel("models/player/combine_soldier_prisonguard.mdl") 
		ply:Give("weapon_stunstick")
		ply:SetWalkSpeed(240)
		ply:SetRunSpeed(400)
		ply:Give("weapon_smg1")
		ply:GiveAmmo(160, "smg1")
		ply:SetHealth(280, true)
	elseif T1C1 == 2 then
		ply:SetModel("models/combine_super_soldier.mdl")
		ply:Give("weapon_stunstick")
		ply:SetWalkSpeed(185)
		ply:SetRunSpeed(320)
		ply:Give("weapon_ar2")
		ply:GiveAmmo(200, "ar2")
		ply:GiveAmmo(1, "grenade")
		ply:SetHealth(350, true)					
	elseif T1C1 == 3 then
		ply:SetModel("models/player/combine_soldier.mdl")
		ply:Give("weapon_stunstick")
		ply:SetWalkSpeed(250)
		ply:SetRunSpeed(380)
		ply:Give("weapon_smg1")
		ply:GiveAmmo(160, "smg1")
		ply:SetHealth(280, true)
	elseif T1C1 == 4 then
		ply:SetModel("models/player/police.mdl")
		ply:Give("weapon_stunstick")
		ply:SetWalkSpeed(295)
		ply:SetRunSpeed(480)
		ply:Give("weapon_pistol")
		ply:GiveAmmo(100, "pistol")
		ply:SetHealth(160, true)
	elseif T1C1 == 5 then
		ply:SetModel("models/player/Group01/male_02.mdl")
		ply:SetWalkSpeed(310)
		ply:SetRunSpeed(512)	
		ply:Give("weapon_357")
		ply:Give("weapon_crowbar")
		ply:GiveAmmo(15 ,"357")
		ply:SetHealth(85, true)
	elseif T1C1 == 6 then
		ply:SetModel("models/player/Group01/female_03.mdl")
		ply:SetWalkSpeed(310)
		ply:SetRunSpeed(512)
		ply:Give("weapon_pistol")
		ply:GiveAmmo(30 , "pistol")
		ply:Give("weapon_crowbar")
		ply:SetHealth(100, true)	
	elseif T1C1 == 7 then
		ply:SetModel("models/player/Group01/female_07.mdl")
		ply:SetWalkSpeed(345)
		ply:SetRunSpeed(550)
		ply:GiveAmmo(3, "slam")
		ply:Give("weapon_crowbar")
		ply:SetHealth(95, true)		
	elseif T1C1 == 8 then
		ply:SetModel("models/player/Group02/male_03.mdl")
		ply:SetWalkSpeed(280)
		ply:SetRunSpeed(480)
		ply:Give("weapon_crowbar")
		ply:GiveAmmo(48, "smg1")
		ply:Give("weapon_smg1")
		ply:SetHealth(125, true)	
	elseif T1C1 == 9 then
		ply:SetModel("models/humans/Group03/female_07.mdl")
		ply:SetWalkSpeed(330)
		ply:SetRunSpeed(535)
		ply:Give("weapon_357")
		ply:GiveAmmo(18, "357")
		ply:Give(2, "item_healthkit")
		ply:Give("weapon_crowbar")
		ply:SetHealth(50, true)	
	end	
end	
if ply:Team() == 2 then PrintMessage(HUD_PRINTTALK, "You are actually in the Team : "..ply:Team()..".")
	local T2C1 = math.random(1, 5)
				
		if T2C1 == 1 then
			ply:SetModel("models/player/classic.mdl")
			ply:SetWalkSpeed(380)
			ply:SetRunSpeed(595)
			ply:Give("weapon_crowbar")
			ply:SetHealth(1150, true)
		elseif T2C1 == 2 then
			ply:SetModel("models/player/Zombiefast.mdl")
			ply:SetWalkSpeed(420)
			ply:SetRunSpeed(655)
			ply:Give("weapon_crowbar")
			ply:SetHealth(500, true)
		elseif T2C1 == 3 then
			ply:SetModel("models/player/zombie_soldier.mdl")
			ply:SetWalkSpeed(320)
			ply:SetRunSpeed(550)
			ply:Give("weapon_crowbar")
			ply:SetHealth(1300, true)	
		elseif T2C1 == 4 then
			ply:SetModel("models/player/charple01.mdl")
			ply:SetWalkSpeed(400)
			ply:SetRunSpeed(610)
			ply:Give("weapon_crowbar")
			ply:SetHealth(920, true)	
		elseif T2C1 == 5 then
			ply:SetModel("models/player/corpse1.mdl")
			ply:SetWalkSpeed(390)
			ply:SetRunSpeed(610)
			ply:Give("weapon_crowbar")
		end	ply:SetHealth(1170, true)
		if teamcheck == 4 then ply:SetTeam(3)
			ply:SetModel("models/player/kleiner.mdl")
			ply:StripWeapons()		
			ply:Give("gmod_camera")
			ply:SetHealth(100, true) 
			ply:SetWalkSpeed(250)
			ply:SetRunSpeed(400)
						
		end
	end
end	


///////// CONSOLE FUNCTION ///////////////
function showhelp(ply)
print("#################################################################################")
print("#  !Plague Roleplay Pre alpha v0.37                                             #")
print("#  List of commands:                                                            #")
print("#                                                                               #")
print("#  1. prp_help        Show up this message.                                     #")
print("#  2. prp_become_sp:  Allow you to switch as Spectator.                         #")
print("#  3. prp_become_Su:  Allow you to turn in the Survivor Team.                   #")
print("#  4. prp_become_in:  Allow you to turn in the Infected Team.                   #")
print("#  5. prp_team:       Show your current Team ID                                 #")
print("#################################################################################")
end
function spect(ply)
ply:StripWeapons()
ply:SetTeam(3)
ply:Respawn()
end
function infect(ply)
ply:StripWeapons()
ply:SetTeam(2)
ply:Respawn()

end
function surv(ply)
ply:StripWeapons()
ply:SetTeam(1)
ply:Respawn()
end
function tteam(ply)
		PrintMessage(HUD_PRINTTALK, "You are actually in the Team : "..ply:Team()..".")
end



///////// CONSOLE COMMANDS /////////////////
concommand.Add("prp_help", showhelp)
concommand.Add("prp_become_sp", spect)
concommand.Add("prp_become_in", infect) 									//-------- ("command_Name", Script Function)
concommand.Add("prp_become_Su", surv)  
concommand.Add("prp_team", tteam) 
//concommand.Add(,)
//concommand.Add(,)


///////// INFECTION MECHANISM ///////////
function GM:PlayerDeath(ply, inflictor, attacker)
	if ply:Team() == 1 and attacker:Team() == 2 then // -- If the player get killed by an infected
		PrintMessage(HUD_PRINTTALK, ply:Name().. " Has been Infected by " ..attacker:Name().. ".")
		ply:StripWeapons()
		ply:SetTeam(2)
		ply:Respawn()
hook.Add("PlayerSpawn", "PlayerSpawn", GM:PlayerSpawn(ply) )

		
	elseif (ply:SteamID() == attacker:SteamID()) then
		PrintMessage(HUD_PRINTTALK, ply:Name().. " committed suicide.")
		ply:StripWeapons()
		ply:SetTeam(3)
		ply:Respawn()
hook.Add("PlayerSpawn", "PlayerSpawn", GM:PlayerSpawn(ply) )

	elseif (ply:Team() == 2) then
		PrintMessage(HUD_PRINTTALK, ply:Name().. " Has been killed by " ..attacker:Name().. ".")
		ply:SetTeam(3)
		ply:Respawn()
hook.Add("PlayerSpawn", "PlayerSpawn", GM:PlayerSpawn(ply) )
	else
		ply:SetTeam(3)
		ply:Respawn()

	end
end
hook.Add("PlayerSpawn", "PlayerSpawn", GM:PlayerSpawn(ply) )

That code certainly is… interesting.

It is still my First attempt and a heavy WIP Gamemode. I will have to find ways to optimize it, I am sure there are plenty of things I could have done better.

A quick description of the Gamemode:

Players are divided in 3 teams. Survivors, Infected and Spectators

It is a RP like gamemode based on Zombie survival. as for now the players model are randomly chosen by the system until i get started on player select menu and gui.

I planned to include 2 Team both of them have 2 Class. As for now I am only Missing the Last Class of the Infected. I need more player model

Survivor are combine soldier and Civilian. both are not Friendly but they can teammate if they wish to.

When someone die from anything he get to spectator mode until the game finish. Unless an infected killed him. If it is the case he become an infected.

I will indroduce Money system and XP to make your guys level up and buy new equipment for survival. there will be a shop at the Lobby where you are free to buy everything you want.

Right now I am at the Testing phase. I need to test out how well the team transition happen etc.
Sadly the game just crash

Is this game mode going up on kickstarter?

Nah maybe just Steam workshop :stuck_out_tongue:

You’re better off using Player Classes with the player_manager library

Then handle player runclass calls within the gamemode hooks.

Ok I got it working almost perfectly. There is just a silly error popup spawning on the top left…

because of my hook.Add(“PlayerSpawn”, “PlayerSpawn”, GM:PlayerSpawn() )

I added a hook to get to the Function GM:PlayerSpawn else when we revive we lose all the equipment

Why are you hooking PlayerSpawn to itself? That makes no sense.

Idk what to do. It was the only way i was able to get my inventory back when i die.
( The inventory is depending on the random character you have been set on)

I am open to learn as much as I need. It’s my first Gamemode and my first attempt in programation.

This is my init.lua


AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")

include('shared.lua')

// Serverside only stuff goes here

/*---------------------------------------------------------
   Name: gamemode:PlayerLoadout()
   Desc: Give the player the default spawning weapons/ammo
---------------------------------------------------------*/


////////// DEFAULT SETTING /////////
/*-------------------------------------------------------------
	Enter Default Variable here
*/-------------------------------------------------------------


///////// Characters Classes /////////
/*------------------WIP------------------------
############## Comming Soon! ##################
###############################################
## TODO:      Adding different player model  ##
## depending on the Class the player take.   ##
##  The class will give different advantage  ##
## To the player to offer a better gameplay  ##
##   such as Speed, Health, Weapons, ect...  ##
## They will also influence a lot on the     ##
## player's progression                      ##
###############################################
*/---------------------------------------------

/*
function T2C2(ply)
end
*/

/////////ON MAP SPAWN/////////////

function GM:PlayerInitialSpawn(ply)

	PrintMessage(HUD_PRINTTALK, "Welcome" ..ply:Name().. " your SteamID is "..ply:SteamID()..".")
		PrintMessage(HUD_PRINTTALK, "You are actually in the Team : "..ply:Team()..".")
end

///////////// ON PLAYER SPAWN //////////////
function GM:PlayerSpawn(ply)
	local batt = math.random(1, 2)
		if batt == 2 then 
			ply:SetTeam(2)
		elseif batt == 1 then 
			ply:SetTeam(1)
		end
if ply:Team() == 1 then
PrintMessage(HUD_PRINTTALK, "You are actually in the Team : "..ply:Team()..".")
local T1C1 = math.random(1, 9)				
			
	if T1C1 == 1 then 
		ply:SetModel("models/player/combine_soldier_prisonguard.mdl") 
		ply:Give("weapon_stunstick")
		ply:SetWalkSpeed(240)
		ply:SetRunSpeed(400)
		ply:Give("weapon_smg1")
		ply:GiveAmmo(160, "smg1")
		ply:SetHealth(280, true)
	elseif T1C1 == 2 then
		ply:SetModel("models/combine_super_soldier.mdl")
		ply:Give("weapon_stunstick")
		ply:SetWalkSpeed(185)
		ply:SetRunSpeed(320)
		ply:Give("weapon_ar2")
		ply:GiveAmmo(200, "ar2")
		ply:GiveAmmo(1, "grenade")
		ply:SetHealth(350, true)					
	elseif T1C1 == 3 then
		ply:SetModel("models/player/combine_soldier.mdl")
		ply:Give("weapon_stunstick")
		ply:SetWalkSpeed(250)
		ply:SetRunSpeed(380)
		ply:Give("weapon_smg1")
		ply:GiveAmmo(160, "smg1")
		ply:SetHealth(280, true)
	elseif T1C1 == 4 then
		ply:SetModel("models/player/police.mdl")
		ply:Give("weapon_stunstick")
		ply:SetWalkSpeed(295)
		ply:SetRunSpeed(480)
		ply:Give("weapon_pistol")
		ply:GiveAmmo(100, "pistol")
		ply:SetHealth(160, true)
	elseif T1C1 == 5 then
		ply:SetModel("models/player/Group01/male_02.mdl")
		ply:SetWalkSpeed(310)
		ply:SetRunSpeed(512)	
		ply:Give("weapon_357")
		ply:Give("weapon_crowbar")
		ply:GiveAmmo(15 ,"357")
		ply:SetHealth(85, true)
	elseif T1C1 == 6 then
		ply:SetModel("models/player/Group01/female_03.mdl")
		ply:SetWalkSpeed(310)
		ply:SetRunSpeed(512)
		ply:Give("weapon_pistol")
		ply:GiveAmmo(30 , "pistol")
		ply:Give("weapon_crowbar")
		ply:SetHealth(100, true)	
	elseif T1C1 == 7 then
		ply:SetModel("models/player/Group01/female_07.mdl")
		ply:SetWalkSpeed(345)
		ply:SetRunSpeed(550)
		ply:GiveAmmo(3, "slam")
		ply:Give("weapon_crowbar")
		ply:SetHealth(95, true)		
	elseif T1C1 == 8 then
		ply:SetModel("models/player/Group02/male_03.mdl")
		ply:SetWalkSpeed(280)
		ply:SetRunSpeed(480)
		ply:Give("weapon_crowbar")
		ply:GiveAmmo(48, "smg1")
		ply:Give("weapon_smg1")
		ply:SetHealth(125, true)	
	elseif T1C1 == 9 then
		ply:SetModel("models/humans/Group03/female_07.mdl")
		ply:SetWalkSpeed(330)
		ply:SetRunSpeed(535)
		ply:Give("weapon_357")
		ply:GiveAmmo(18, "357")
		ply:Give(2, "item_healthkit")
		ply:Give("weapon_crowbar")
		ply:SetHealth(50, true)	
	end	
end	
if ply:Team() == 2 then PrintMessage(HUD_PRINTTALK, "You are actually in the Team : "..ply:Team()..".")
	local T2C1 = math.random(1, 5)
				
		if T2C1 == 1 then
			ply:SetModel("models/player/classic.mdl")
			ply:SetWalkSpeed(380)
			ply:SetRunSpeed(595)
			ply:Give("weapon_crowbar")
			ply:SetHealth(1150, true)
		elseif T2C1 == 2 then
			ply:SetModel("models/player/Zombiefast.mdl")
			ply:SetWalkSpeed(420)
			ply:SetRunSpeed(655)
			ply:Give("weapon_crowbar")
			ply:SetHealth(500, true)
		elseif T2C1 == 3 then
			ply:SetModel("models/player/zombie_soldier.mdl")
			ply:SetWalkSpeed(320)
			ply:SetRunSpeed(550)
			ply:Give("weapon_crowbar")
			ply:SetHealth(1300, true)	
		elseif T2C1 == 4 then
			ply:SetModel("models/player/charple01.mdl")
			ply:SetWalkSpeed(400)
			ply:SetRunSpeed(610)
			ply:Give("weapon_crowbar")
			ply:SetHealth(920, true)	
		elseif T2C1 == 5 then
			ply:SetModel("models/player/corpse1.mdl")
			ply:SetWalkSpeed(390)
			ply:SetRunSpeed(610)
			ply:Give("weapon_crowbar")
		end	ply:SetHealth(1170, true)
		if teamcheck == 4 then ply:SetTeam(3)
			ply:SetModel("models/player/kleiner.mdl")
			ply:StripWeapons()		
			ply:Give("gmod_camera")
			ply:SetHealth(100, true) 
			ply:SetWalkSpeed(250)
			ply:SetRunSpeed(400)
						
		end
	end
end	


///////// CONSOLE FUNCTION ///////////////
function showhelp(ply)
print("#################################################################################")
print("#  !Plague Roleplay Pre alpha v0.37                                             #")
print("#  List of commands:                                                            #")
print("#                                                                               #")
print("#  1. prp_help        Show up this message.                                     #")
print("#  2. prp_become_sp:  Allow you to switch as Spectator.                         #")
print("#  3. prp_become_Su:  Allow you to turn in the Survivor Team.                   #")
print("#  4. prp_become_in:  Allow you to turn in the Infected Team.                   #")
print("#  5. prp_team:       Show your current Team ID                                 #")
print("#################################################################################")
end
function spect(ply)
ply:StripWeapons()
ply:SetTeam(3)
ply:Respawn()
end
function infect(ply)
ply:StripWeapons()
ply:SetTeam(2)
ply:Respawn()

end
function surv(ply)
ply:StripWeapons()
ply:SetTeam(1)
ply:Respawn()
end
function tteam(ply)
		PrintMessage(HUD_PRINTTALK, "You are actually in the Team : "..ply:Team()..".")
end



///////// CONSOLE COMMANDS /////////////////
concommand.Add("prp_help", showhelp)
concommand.Add("prp_become_sp", spect)
concommand.Add("prp_become_in", infect) 									//-------- ("command_Name", Script Function)
concommand.Add("prp_become_Su", surv)  
concommand.Add("prp_team", tteam) 
//concommand.Add(,)
//concommand.Add(,)


///////// INFECTION MECHANISM ///////////
function GM:PlayerDeath(ply, inflictor, attacker)
	if ply:Team() == 1 and attacker:Team() == 2 then // -- If the player get killed by an infected
		PrintMessage(HUD_PRINTTALK, ply:Name().. " Has been Infected by " ..attacker:Name().. ".")
		ply:StripWeapons()
		ply:SetTeam(2)
		ply:Respawn()
hook.Add("PlayerSpawn", "PlayerSpawn", GM:PlayerSpawn(ply) )

		
	elseif (ply:SteamID() == attacker:SteamID()) then
		PrintMessage(HUD_PRINTTALK, ply:Name().. " committed suicide.")
		ply:StripWeapons()
		ply:SetTeam(3)
		ply:Respawn()
hook.Add("PlayerSpawn", "PlayerSpawn", GM:PlayerSpawn(ply) )

	elseif (ply:Team() == 2) then
		PrintMessage(HUD_PRINTTALK, ply:Name().. " Has been killed by " ..attacker:Name().. ".")
		ply:SetTeam(3)
		ply:Respawn()
hook.Add("PlayerSpawn", "PlayerSpawn", GM:PlayerSpawn(ply) )
	else
		ply:SetTeam(3)
		ply:Respawn()

	end
end
hook.Add("PlayerSpawn", "PlayerSpawn", GM:PlayerSpawn(ply) )

Seems like you’ve taken a lot of this from an old wiki tutorial. I’d recommend familiarizing yourself more with Lua and make some smaller scripts before attempting to make an entire gamemode.

Yeah… I made all of it after watching like 3 Lua tutorial for Gmod on youtube. You have a point though. I just like to challenge myself.

You’ll challenge yourself when you have the skill to afford that. For now, think small. Make small toys, they could be weapons, entities, console commands that grant you some kind of superpower, or absolutely anything. Make a lot of them, try to code any idea that crosses your mind, or if you don’t have any, just take an addon you like and modify it.

What’s important is that you need to start doing small things, become a bit more familiar with Lua, and then once you think you’re starting to understand it all, take everything you have done so far and try to make a gamemode out of it.

That’s how you make original gamemodes.

[editline]dick[/editline]

Also, another important thing: code for yourself, not for other people. Don’t try to make something you will release, but make something you will have fun with. I know it’s very tempting to do the next big RP gamemode or admin mod or whatever, but you will learn absolutely nothing from that. Most GMod mechanics are best learned by making physics toys, silly creative things that have their place in a toy box but aren’t necessarily worth releasing. Of course, you can always release them just to get constructive criticism, but basically, don’t code with releasing in mind.

Oh and don’t slap silly version numbers on everything you make. We all wanted to do that at some point because arguably, “version alpha 0.19.254 build 1652” looks kinda cool to you, but it’s a bit ridiculous when you think of it. Plus that’s not even how alpha and beta stages work.

[editline]dick2[/editline]

Useful links:

Lua Reference Manual
Don’t read all of it immediately because it will make you confused and some base Lua libraries don’t even exist in GMod (notably the io library). But it’s quite useful if you need to know how some base Lua functions work, especially the string and table libraries.

Programming In Lua
This one is a must. Read it. It explains how to properly use Lua and teaches you a bunch of useful tricks.

Lua live demo
I personally use this one a lot. It lets you experiment with Lua without having to run GMod or download the Lua interpreter. It’s quite useful for testing complicated algorithms or trying things with tables and strings. As long as you’re not using GMod specific functions, of course.

Garry’s Mod Wiki
You probably know about this one already.

[editline]6th September 2013[/editline]

Also while I’m at it, I’ll point out your most outrageous mistakes so you never do them again. The way you wrote your gamemode is a bit questionable too (for instance, players are assigned to a random team every time they spawn, and they instantly respawn on death), but I’ll not go into that.

[lua] local batt = math.random(1, 2)
if batt == 2 then
ply:SetTeam(2)
elseif batt == 1 then
ply:SetTeam(1)
end[/lua]

Redundant conditions. That one is a classic. You could have simply used ply:SetTeam(math.random(1, 2)) instead.

[lua] if T1C1 == 1 then

elseif T1C1 == 2 then

elseif T1C1 == 3 then

elseif T1C1 == 4 then

elseif T1C1 == 5 then

elseif T1C1 == 6 then

elseif T1C1 == 7 then

elseif T1C1 == 8 then

elseif T1C1 == 9 then

end[/lua]

Loads of if then elseif then elseif then elseif then… that do essentially the same thing with different values. If you have this in your code, there’s a very good chance that you’re doing something wrong. You can make this a lot shorter and with much less repeating code by using tables instead.

[lua]hook.Add(“PlayerSpawn”, “PlayerSpawn”, GM:PlayerSpawn(ply) )[/lua]

Look I don’t know what you were even trying to do there but just don’t do that again. First of all hook.Add basically adds a function to be called before the main gamemode hook gets called (GM.PlayerSpawn, in this case). So basically, you’re telling the game to call GM.PlayerSpawn before GM.PlayerSpawn gets called. See the problem here?
Not only that, but you’re not even doing it right. The third argument to hook.Add is supposed to be a function, however what you wrote here basically means “call GM.PlayerSpawn with ply as its first parameter, take the result and add it to the list of hooks for the PlayerSpawn event”. So it will immediately call GM.PlayerSpawn, which returns nothing, and then adds nothing to the list of hooks. Nonsense. The “right” way to write it would be hook.Add(“PlayerSpawn”, “PlayerSpawn”, GM.PlayerSpawn), and even then you shouldn’t do that because it’s plain stupid.

Also adding hooks is a one time operation. You do it once and the game will remember it for the current session until you manually remove the hook (using hook.Remove). So you shouldn’t add it every time the player dies.

Thanks for the tips, I appreciate it a lot. I will take my time working on a few things then maybe work on that gamemode later.

uh yeah… :3 idk how it work but its the 37th update/changes i have made not counting small adjustment
Thank you for your tips

i forgot to say that we spawn randomly into class because I didnt made the player selector vgui yet. It was only for testing if every characters were working fine and if the transition was good enough.
I had nobody to test it with me though.