Garry's Mod, Need some help with LUA

I’m just trying to make function which would give to player armor if he has certain bodygroup on his playermodel. But it goes bad beacause of my knowledge of lua. Could you help me?


function Player:FindBodygroupByName( string "Armor" );
	player:SetArmor( 0 );

if string == "Armor" then
	player:SetArmor( 100 );
else
	player:SetArmor( 0 );
end

Can you paste your entire code in


 [/code.] tags?

Did it

You’ve obviously looked at this wiki page:

Entity:FindBodygroupByName which is a good start. However, I don’t think you understand basic Lua.

In your code ‘Player’ and ‘player’ are nil. Also, you need to read up on how arguments work.

Why don’t you give it another try? I don’t think giving you completed code is a good idea since you won’t learn anything

I would try to learn some basics, but I dont know where to start from?

I would start by referring to this: https://www.lua.org/pil/contents.html

Similarly, you will need to use a hook to run your code (and also give you a player object), so take a look at this too: http://wiki.garrysmod.com/page/Hook_Library_Usage

Thanks a lot!