for table fucked up (GMStranded)

Hello, I tried making a concommand, which gives the targeted players all weapons as a test(autocomplete working fine), but when it comes to p:Give() it returns a error.

Here’s the function I use:

concommand.Add("cstranded_givealltools", function(ply, cmd, args)
	local target = args[1]

	for _, p in pairs(player.GetAll()) do
		if p:Nick() == target then
			for _, w in pairs(GMS.AllWeapons) do
end, customstranded.autocompletenames)

And here is the error:

[ERROR] addons/gmstranded_custom/lua/autorun/sv_concommands.lua:53: attempt to call method 'Give' (a nil value)
  1. unknown - addons/gmstranded_custom/lua/autorun/sv_concommands.lua:53
   2. unknown - lua/includes/modules/concommand.lua:54

I dont know how to fix that, a note also is, when I print out “w” using PrintMessage, it puts everything on one line, not like with player.GetAll() where it puts linebreaks, maybe thats the cause? if yes, I dont know how to fix that…

What colour is the error?


You are trying to call serverside functions on client.

Its on a server file though? How should I give a player the weapon else?

If the error is a clientside error, then it is being called on the client. What file is it?


and theres no AddCSLuaFile() line.

if you run a command in client, this will run in clientside, you must use netmessages

Pretty sure files in lua/autorun are ran both serverside and clientside, put it in lua/autorun/server.
The sv prefix has no meaning here in your file name, those are usually used by module loaders.

Or by people who wants to sort they stuf, so they can know on 1 lookover, which scripts are loaded cl, sv and sh :slight_smile:

Still getting the same error :confused:

Is the error still yellow?


Can you say the exact path to your file?
If it is in somewhere/lua/autorun/server/ then you must have it somewhere client too
If you have it in lua/autorun/ then it’s loaded on client and server, put if( SERVER ) then //code end

or you can just do: if ( CLIENT ) then return end