Eranthis Posted March 7, 2018 Share Posted March 7, 2018 (edited) Not something I think can likely be achieved but I was wondering if there was any way to have a character start a game equipped with an item. My reason for asking is that the custom item I have is a backpack and I'd like it to function much like the vanilla backpack where characters can't keep the item in their inventory as to avoid abusing its extra inventory slots. However because it can't be stored in inventory, the character won't actually start with the item. If this isn't possible, I'd then ask if it's possible to script a way for a player to only keep one of said item in their inventory. Edited March 8, 2018 by Eranthis Link to comment https://forums.kleientertainment.com/forums/topic/88412-solved-equippable-starting-items/ Share on other sites More sharing options...
IronHunter Posted March 8, 2018 Share Posted March 8, 2018 In your master_postinit add the following code if it doesn't exist or add it to the OnNewSpawn function if it does. inst.OnNewSpawn = function() local backpack = SpawnPrefab("backpack") --change the "backpack" to your prefab name inst.components.inventory:Equip(backpack) end Cheers, Iron_Hunter Link to comment https://forums.kleientertainment.com/forums/topic/88412-solved-equippable-starting-items/#findComment-1012208 Share on other sites More sharing options...
Eranthis Posted March 8, 2018 Author Share Posted March 8, 2018 (edited) 17 hours ago, IronHunter said: In your master_postinit add the following code if it doesn't exist or add it to the OnNewSpawn function if it does. inst.OnNewSpawn = function() local backpack = SpawnPrefab("backpack") --change the "backpack" to your prefab name inst.components.inventory:Equip(backpack) end Cheers, Iron_Hunter Alright that solved it. Thanks! Edited March 8, 2018 by Eranthis Link to comment https://forums.kleientertainment.com/forums/topic/88412-solved-equippable-starting-items/#findComment-1012466 Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now