Limiting weapons on spawn

Alright, lemme make myself a little bit clearer

I want a lua script that will get rid of all weapons when I spawn.
Keep in mind, this is for singleplayer, so I can’t just use an admin mod.
It would be nice to make the script easy to edit, or better yet, and a derma panel in Utilities or Options that would make it editable in game.
Would also be nice if it could get rid of ammo when I spawn as well, but I would just settle for weapons.

Two weeks - Anybody?

Bi weekly bump here. ;_;

local weapons = {
local ammo = {
“Pistol” = 25,
“AR2” = 1337,
“SMG1” = 101
hook.Add( “PlayerLoadout”, “SetWeaponsOnSpawn”, function( ply )

for k, v in pairs( weapons ) do

    ply:Give( v )


for k, v in pairs( ammo ) do

    ply:GiveAmmo( v, k, true )

return true

There is weapons list
and there ammo list
Put it in lua/autorun/server/

hook.Add("PlayerSpawn", "StripAll", function(ply) ply:StripWeapons() end )

I’m sorry if I may have been a little unclear.
I wanted it to strip CERTAIN weapons, not all, and then maybe give me new ones.
But it doesn’t matter, this has already been answered above you.

Just a little unclear, yes.

Doesn’t work.

[lua]local weapons = {

for _,v in ipairs(weapons) do ply:Give(v) end
return true

This man wins.

Incidentally if you want to just spawn with a physgun/toolgun/camera and nothing else in sandbox, you can do it in one line.
[lua]CreateConVar(“sbox_weapons”,0,{ FCVAR_REPLICATED, FCVAR_ARCHIVE })[/lua] in any serverside autorun file.

Problem is, sbox_weapons does not do anything when I run it in console. I dunno if it will do it via lua, but hey.
That, and I’d like to edit my spawn weapons, which sbox_weapons won’t let me do.

That’s because Garry is an idiot. You have to create it first, with that code, then it works.

Your welcome.

hi bit of a noob here but was wondering where i put this

my folders basicly go like this garrysmod/lua/autorun/client i then create a file called autorun.lua with this but i keep getting an error in gmod saying

autorun/client/Autorun.lua:1: unexpected symbol near ‘1.’

Put it in lua/autorun/server/Autorun.lua

i did exactly what jamie said and im getting the exact same results
i even reinstalled gmod but nope anyone know why?


side not heres what the console says in full

Lua initialized (Lua 5.1)
autorun/client/Autorun.lua:1: unexpected symbol near ‘1.’
Registering gamemode ‘sandbox’ derived from ‘base’


also just like to point out that i dont seem to have any problems when doing this at college seems to only go wrong when im at home dont see why tho has i stated ive reinstalled it at home, i even tryed the scripting written above to strip ALL weapons and that didnt work eithe, lua just doesnt seem to want to work on my home pc anyone got any suggestions?

Did you copy it directly from the lua tag and kept the hash signs? (#) These are not part of the script.
If so next time click view plain first to get the actual code.
Here’s what you want to use :

local weapons = {

	for _,v in ipairs(weapons) do ply:Give(v) end
	return true

BINGO absoulutely fantastic cheers mate

Yeah, before you copy and paste a code, at the top of the box, there should be a button called view plain. Click that and copy it.