WHY DOESNT THIS SHIT WORK

I made basewars for gmod13 and i got some errors:
[ERROR] gamemodes/basewars/gamemode/cl_buymenu.lua:51: attempt to concatenate field ‘Model’ (a nil value)

  1. DoPopulate - gamemodes/basewars/gamemode/cl_buymenu.lua:51
  2. DoClick - gamemodes/basewars/gamemode/cl_buymenu.lua:68
    3. InternalDoClick - lua/vgui/dtree_node.lua:81
    4. fn - gamemodes/basewars/gamemode/cl_buymenu.lua:78
    5. Call - addons/ulib/lua/ulib/shared/hook.lua:168
    6. CallPopulateHook - …dbox/gamemode/spawnmenu/creationmenu/content/content.lua:49
    7. Function - gamemodes/basewars/gamemode/cl_buymenu.lua:86
    8. unknown - gamemodes/sandbox/gamemode/spawnmenu/creationmenu.lua:42

it also stays at sandbox gamemode. I did try gamemode Basewars | gamemode “basewars”| gamemode “Basewars”|gamemode basewars

[lua]local Panel = vgui.Create( “DFrame” )
Panel:Hide()

hook.Add( “PopulateBasewars”, “AddEntityContent”, function( pnlContent, tree, node )

local Categorised = {}

-- Add this list into the tormoil
local SpawnableEntities = scripted_ents.GetSpawnable()

for k,v in pairs(SpawnableEntities) do --Remove all non basewars items
    if v.Price == nil then
        table.remove(SpawnableEntities, k)
    end
end

if ( SpawnableEntities ) then
    for k, v in pairs( SpawnableEntities ) do
        v.Category = v.Category or "Other"
        Categorised[ v.Category ] = Categorised[ v.Category ] or {}
        table.insert( Categorised[ v.Category ], v )
        
    end
end

--
-- Add a tree node for each category
--
for CategoryName, v in SortedPairs( Categorised ) do
                
    -- Add a node to the tree
    local node = tree:AddNode( CategoryName, "icon16/bricks.png" );

        -- When we click on the node - populate it using this function
    node.DoPopulate = function( self )

        -- If we've already populated it - forget it.
        if ( self.PropPanel ) then return end
    
        -- Create the container panel
        self.PropPanel = vgui.Create( "ContentContainer", pnlContent )
        self.PropPanel:SetVisible( false )
        self.PropPanel:SetTriggerSpawnlistChange( false )
    
        for k, ent in SortedPairsByMemberValue( v, "PrintName" ) do
                        
            local Icon = spawnmenu.CreateContentIcon( ent.ScriptedEntityType or "entity", self.PropPanel,
            {
                nicename = ent.PrintName or ent.ClassName,
                spawnname = ent.ClassName,
                material = "materials/spawnicons/"..ent.Model,
                admin = ent.AdminOnly || ( !ent.Spawnable && ent.AdminSpawnable )
                        
            })
            Icon.DoClick = function ()
                LocalPlayer():ConCommand("buy_entity "..ent.ClassName)
            end
            local Tooltip = Format( "Name: %s

Price: %s", ent.PrintName, ent.Price )
Icon:SetTooltip( Tooltip )

        end
                
    end

    -- If we click on the node populate it and switch to it.
    node.DoClick = function( self )

        self:DoPopulate()
        pnlContent:SwitchPanel( self.PropPanel );

    end

end

-- Select the first node
local FirstNode = tree:Root():GetChildNode( 0 )
if ( IsValid( FirstNode ) ) then
    FirstNode:InternalDoClick()
end

end )

spawnmenu.AddCreationTab( “Basewars”, function()

local ctrl = vgui.Create( "SpawnmenuContentPanel" )
ctrl:CallPopulateHook( "PopulateBasewars" );

return ctrl

end, “icon16/basket.png”, 20 )[/lua]

I Have This Problem Too :frowning:

You could use ent:GetModel() and then trim some of the returned string since it wouldn’t be a correct path without doing it.

ok i do this but now im getting this error

[ERROR] gamemodes/basewars/gamemode/cl_buymenu.lua:47: unexpected symbol near ‘local’

  1. unknown - gamemodes/basewars/gamemode/cl_buymenu.lua:0

Applyed Code:
//////////////////////////////////////////////////////////////////////////
for k, ent in SortedPairsByMemberValue( v, “PrintName” ) do
(
local Icon = spawnmenu.CreateContentIcon( ent.ScriptedEntityType or “entity”, self.PropPanel,

                nicename    = ent.PrintName or ent.ClassName,
                spawnname   = ent.ClassName,
                material    = "materials/spawnicons/"..ent:GetModel()
                admin       = ent.AdminOnly || ( !ent.Spawnable && ent.AdminSpawnable )
              ))      

//////////////////////////////////////////////////////////////////////////

You should try posting in the lua section, you’re more likely to get help there.

First of all, this is not your’s basewars… It’s RGaming. Check their Github.
Second, shouldn’t do this if you don’t know how to fix it.

How’s this relevant?