Function Error

So im getting an error when loading my gamemode, here is the code.

[lua]function rp_team1( ply )

ply:SetTeam( 1 )
ply:SetModel( "models/player/group01/" )

This is the code for changing team but im getting this error:

Roleplay/gamemode/init.lua:71: function arguments expected near ‘ply’

You missed ‘()’ after ‘Spawn’ and ‘UnSpectate’.


Also “models/player/group01/” isn’t a valid model.

First, yeah thank you I figured out the () and what is the citizen group of model??

Also I have an error with Derma, the DFrame is not showing up, I put it in cl_init, but when I try loading it with lua_openscript I get that error:

Roleplay\gamemode\shared.lua:1: attempt to index global ‘GM’ (a nil value)
Roleplay\gamemode\init.lua:7: attempt to index global ‘GM’ (a nil value)

Ahem. Stop creating global functions which should be LOCAL.

Oh when im writing the Console command of the DFrame, its getting that error too:

Roleplay/gamemode/cl_init.lua:11: attempt to index global ‘vgui’ (a nil value)

Post your code so we can help you. Otherwise, you’re walking blindfolded trying to find your way around, while we give you directions.

I dont really now whats a Local or a Global function…




What code do you want me to put?? Ill put the Derma code


[lua]function set_team()

local Ready = vgui.Create( “DFrame” )
Ready:SetPos( ScrW() / 2, ScrH() / 2 )
Ready:SetSize( 250, 250 )
Ready:SetTitle( “Choose your job” )
Ready:SetVisible( true )
Ready:SetDraggable( false )
Ready:ShowCloseButton( false )

local ready1 = vgui.Create( “DButton”, Ready )
ready1:SetPos( 20, 25 )
ready1:SetSize( 100, 40 )
ready1:SetText( “Citizen” )
ready1.DoClick = function()
RunConsoleCommand( “rp_team1” )


local ready2 = vgui.Create( “DButton”, Ready )
ready2:SetPos( 20, 40 )
ready2:SetSize( 100, 40 )
ready2:SetText( “Police” )
ready2.DoClick = function()
RunConsoleCommand( “rp_team2” )


local ready3 = vgui.Create( “DButton”, Ready )
ready3:SetPos( 20, 55 )
ready3:SetSize( 100, 40 )
ready3:SetText( “Gangster” )
ready3.DoClick = function()
RunConsoleCommand( “rp_team3” )

local ready4 = vgui.Create( “DButton”, Ready )
ready4:SetPos( 20, 70 )
ready4:SetSize( 100, 40 )
ready4:SetText( “Drug dealer” )
ready4.DoClick = function()
RunConsoleCommand( “rp_team4” )



concommand.Add( “team_menu”, set_team )
usermessage.Hook( “team_menu”, set_team )[/lua]