Unnecessarily bump. 
I got this code: 
Server-side 
  
  
addEvent ( "objcrt", true ); 
addEventHandler ( "objcrt", root, 
    function ( chk ) 
        outputChatBox ( tostring ( chk ) ); -- check here what outputs 
        
        toggleAllControls ( source, true ); 
        showCursor ( source, false );  
        local nX, nY, nZ = getElementPosition ( source ); 
        local nX2, nY2 = 0, 0 
        local nZ2 = getPedRotation( source ) 
        if ( chk == 0 ) then 
            rbobj0 = createObject(1459, nX, nY, nZ-0.5, nX2, nY2, nZ2); 
        elseif ( chk == 1 ) then 
            rbobj1 = createObject(1424, nX, nY, nZ-0.5, nX2, nY2, nZ2); 
        elseif ( chk == 2 ) then 
            rbobj2 = createObject(1425, nX, nY, nZ-0.5, nX2, nY2, nZ2); 
        elseif ( chk == 3 ) then 
            rbobj3 = createObject(1423, nX, nY, nZ-0.2, nX2, nY2, nZ2); 
        elseif chk == 4 then 
            rbobj3 = createObject(981, nX, nY, nZ-0.5, nX2, nY2, nZ2); 
        elseif chk == 5 then 
            rbobj4 = createObject(978, nX, nY, nZ-0.5, nX2, nY2, nZ2); 
        end 
         
    end 
) 
 
Client-side 
local tRBNames = 
{ 
    [ 'roadright' ]          = 'Small roadblock'; 
    [ 'helix_barrier' ]      = 'Big Street Roadblock'; 
    [ 'roadworkbarrier1' ]   = 'Sidewalk Roadblock'; 
    [ 'roadbarrier4' ]       = 'Barrier'; 
    [ 'roadbarrier3' ]       = 'Detour sign'; 
    [ 'roadbarrier6' ]       = 'Small barrier'; 
} 
  
function cGUI() 
    showCursor(true) 
    toggleAllControls(true) 
    rbsWindow = guiCreateWindow(0.3391,0.2832,0.3125,0.4688,"Roadblock System",true) 
    guiWindowSetSizable(rbsWindow,false) 
    acceptButton = guiCreateButton(0.1075,0.8813,0.3225,0.0854,"Accept",true,rbsWindow) 
    closeButton = guiCreateButton(0.57,0.8813,0.3225,0.0854,"Close",true,rbsWindow) 
    rbsMenu = guiCreateGridList(0.11,0.1292,0.785,0.725,true,rbsWindow) 
    guiGridListSetSelectionMode(rbsMenu,2) 
    guiGridListAddColumn(rbsMenu,"Roadblocks",0.90) 
    for _, sObject in pairs ( tRBNames ) do -- pairs, not ipairs 
      if ( rbsMenu ) then 
            local row = guiGridListAddRow ( rbsMenu ) 
            guiGridListSetItemText ( rbsMenu, row, 1, tostring ( sObject ), false, false ) 
          end 
    end 
    addEventHandler("onClientGUIClick", root, 
      function ( ) 
          if ( source == acceptButton ) then 
                local chk = guiGridListGetSelectedItem ( rbsMenu ) 
                if ( chk ) then   
                  triggerServerEvent("objcrt", localPlayer, chk) --localPlayer, not root 
                    guiSetVisible(rbsWindow, false) 
              end 
            elseif ( source == closeButton ) then 
                guiSetVisible(rbsWindow, false) 
                toggleAllControls(true) 
                showCursor(false) 
            end 
        end 
    ) 
end 
addCommandHandler ( 'rb', cGUI ) 
  
 
How do I make it so that every time I spawn an object, the ID to the object spawned is set? Like, the start ID will be 0, when I spawn an object it will be 1, the next object is 2, without taking the objects in order and so on.