Playerloadout error

Hey, I wrote this piece of code and it keeps bugging me with errors, when I seem to fix one I get another, so I dont see a point posting them all here, but Id appreciate it if you’d edit my code to be error-less.



function GM:PlayerLoadout( ply ) --Sent to the players on teams. (Technically everybody is on the Joining/Connecting team of what ever if there isn't a team in your gamemode.)
 
    ply:SetGravity( 1.00 )  
    ply:SetMaxHealth( 200, true )  
 
    ply:SetWalkSpeed( 125 )  
    ply:SetRunSpeed( 175 ) 
 
    if ply:Team() == 1 then
        ply:Give( "Combo-Fists" )
    elseif ply:Team() == 2 then
        ply:Give( "Combo-Fists" )
    elseif ply:Team() == 3 then
        ply:Give( "Combo-Fists" )
    elseif ply:Team() == 4 then
        ply:Give( "Combo-Fists" )
    elseif ply:Team() == 5 then
        ply:Give( "Combo-Fists" )
    elseif ply:Team() == 6 then
        ply:Give( "Combo-Fists" )
    elseif ply:Team() == 7 then
        ply:Give( "Combo-Fists" )
    elseif ply:Team() == 8 then
        ply:Give( "Combo-Fists" )
    end --end if statement
end --end function


Thanks in advance!

Good god. First of all,


local t = ply:Team()
if t >= 1 and t <= 8 then ply:Give("Combo-Fists") end

Second, what error are you getting? We can’t fix it if we don’t know what it is. You’re probably using the wrong name for the weapon - when you give a player a weapon, you use the weapon class (like “weapon_fists”), not the weapon name.

Ive based this code on a example at the GMod Wiki.
Ive been getting various errors, mostly about an end and a ‘)’

The error I am currently getting with this code is:




RealisticRP/gamemode/init.lua:42: ')' expected (to close '(' at line 34) near 'function'
**********************************************
**********************************************
********** COULDN'T LOAD GAMEMODE!! **********
**********************************************
**********************************************

There was a problem opening the gamemode file 'RealisticRP/gamemode/init.lua'


Registering gamemode 'RealisticRP' derived from 'base'


This isn’t the code that is giving you an error. Like it says the problem is in init.lua

Its fixed.

Thanks anyway guys!