Jump to content

Help making custom backpack for character


Recommended Posts

I'm trying to create a custom backpack for this character, and I want the backpack to show up in their inventory when they spawn in. I've gotten other custom items to work (made a custom weapon), but I can't seem to get the backpack working. whenever I try to spawn into the world, I get this error:

Quote

[string "scripts/components/inventory.lua"]:637: attempt to index local 'inst' (a nil value) LUA ERROR stack traceback: scripts/components/inventory.lua:637 in (method) GiveItem (Lua) <636-769>
scripts/prefabs/player_common.lua:1941 in (method) OnNewSpawn (Lua) <1937-1949>
scripts/networking.lua:250 in () ? (Lua) <238-256>
=[C]:-1 in (method) SendSpawnRequestToServer (C) <-1--1>
scripts/mainfunctions.lua:1289 in (local) cb (Lua) <1287-1290>
scripts/frontend.lua:538 in (method) DoFadingUpdate (Lua) <502-542>
scripts/frontend.lua:590 in (method) Update (Lua) <550-707>
scripts/update.lua:92 in () ? (Lua) <33-129>

any help would be much appreciated

Link to comment
Share on other sites

Better late than never? Where did you put the code for this? It should look something like...

local MakePlayerCharacter = require "prefabs/player_common"

local assets = {
  Asset("SCRIPT", "scripts/prefabs/player_common.lua")
}

local start_inv = {
  "customitem"
}

local function common_postinint(inst)
  ...
end

local function master_postinit(inst)
  ...
end

return MakePlayerCharacter("character_name", prefabs, assets, common_postinit, master_postinit, start_inv)

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...