Stripping weapons help. (Also what are hooks?)

I made a script for Sandbox RP, ( Stupid, I know ) I made it so it strips all the weapons and gives the player weapons on spawn.


hook.Add( "PlayerSpawn", "Rofl P90_Man's Hook :D", function( ply )
    ply:StripWeapons()
    ply:Give( "weapon_physgun" )
    ply:Give( "weapon_physcannon" )
    ply:Give( "gmod_tool" )
    ply:Give( "rcs_knife" )
    ply:Give( "tf2_combo_fists" )
end )

Now I need to know WHY it isn’t working… I ain’t getting the weapons, or losing my others. AND there are NO Errors, when I run it manually so… Also, what is a hook? I’ve been wondering. (Someone told me I needed a hook. So they did it for me.)

Try doing this:



hook.Add( "PlayerSpawn", "Rofl P90_Man's Hook :D", function( ply )
timer.simple(0.1, function()
    ply:StripWeapons()
    ply:Give( "weapon_physgun" )
    ply:Give( "weapon_physcannon" )
    ply:Give( "gmod_tool" )
    ply:Give( "rcs_knife" )
    ply:Give( "tf2_combo_fists" )
end)
end )



[edit]
heh, I just saw that, the hook name could be messing it up. Not positive though. I do know that you need some sort of delay before stripping all the players weapons. As for the “What is a hook” question. You should read up on this.



hook.Add( "PlayerSpawn", "CustomLoadout", function( ply )
timer.simple(0.1, function()
    ply:StripWeapons()
    ply:Give( "weapon_physgun" )
    ply:Give( "weapon_physcannon" )
    ply:Give( "gmod_tool" )
    ply:Give( "rcs_knife" )
    ply:Give( "tf2_combo_fists" )
end)
end )



Thanks! I Will try it out NOW!

[editline]05:42PM[/editline]

Yes, I’m getting lua errors.


Attempt to call field 'simple'. 
Removing Hook *My hook...*

[editline]05:46PM[/editline]

I’m a newbie, so I don’t know pretty much any hooks, functions, or anything.

oh right, sorry, It’s:


timer.Simple

Capitalization matters, I didn’t realize I forgot to capitalize “Simple”, sorry about that.

This should work:



hook.Add( "PlayerSpawn", "CustomLoadout", function( ply )
timer.Simple(0.1, function()
    ply:StripWeapons()
    ply:Give( "weapon_physgun" )
    ply:Give( "weapon_physcannon" )
    ply:Give( "gmod_tool" )
    ply:Give( "rcs_knife" )
    ply:Give( "tf2_combo_fists" )
end)
end )



Thats ok, I didn’t realise, testing again! You’ve been great to me :downs:

P.S, Aussies spell ‘realize’ as ‘realise’

[editline]06:40PM[/editline]

YES IT WORKS! Thanks!