• Problem with script
    11 replies, posted
Hi.I want to create a script, but I have a prolem. local function spawn( player )    print( player:Nick().. " has spawned!." )    player:SetArmor( 100 ) end hook.Add( "PlayerSpawn", "some_unique_name", spawn ) The "print" function is called after each respawn and is works, but player does not receive armor. What the problem is?
Looks like it's overriding player's armor due to player_class settings. Try to use PlayerLoadout hook instead
Does the print statement actually print the players name?
I don't see any problem with the code, if you are hosting a server did you put it in garrysmod > lua > autorun as someuniquename.lua ? Though I would suggest making the code a bit more sorted, that might be the problem, yet I'm not 100% sure, may be someone here can help you more than I could. local function spawn( ply )    print( ply:Nick().. " has spawned!." )    ply:SetArmor(100) end hook.Add( "PlayerSpawn", "some_unique_name", spawn )
yes
lua > autorun > server no need to include it unless that's the route you want to go
@PYfffE you should try this solution, pretty sure this will solve it
I used PlayerLoadout hook and SetArmor works, but I need to manually give weapons to player
Did you override GM function or hooked it?
hook.Add()
Show your code of hook
use the Give function to give players weapon.
Sorry, you need to Log In to post a reply to this thread.