Open Sourced Inventory System

Because most developers can’t script a DataStore module better than ProfileService.

1 Like

You’re right, I just wanted to support ProfileService because I’m gonna be using it for my future games which is gonna need session locking to avoid duplication exploits

1 Like

Amazing work to be fair. I like how the whole system looks organised, looks clean and I’ll definitely try it out.

Anyways great work, thanks for your post!

Hello !
Is it possible to skip the Equi, cancel part and directly equip the tool when the player click on it with left click, and drop it with right click

Thanks for this. It is true that a lot of beginner scripters struggle with inventory systems, so this would be very helpful for the likes of me. However, it gets very confusing to read other people’s code as a beginner especially when the code is not heavily commented. It would be very useful if there are more comments to guide readers because this system is targeted for beginners and it is open sourced.

I’d just delete the parts in the scripts that you don’t want.

Hey just wanted to say amazing work on this open-sourced inventory system. I’m not sure if this is still being worked on but I noticed a bug with the weight system. For some reason, if I hit the maximum amount of weight, then drop items to make room, and try to pick up more items it prevents me from picking up any items. I’m assuming it has to do with this section of the code:

local function AddToSlot(item, userId)
	local tempData = TempDatas[userId]
	local data = Datas[userId]
	local itemInfo = ItemsInfo[item]

	if (tempData.Weight + itemInfo.Weight) > data.MaxWeight then
		print("not enough max weight")
		return false
	end

	if itemInfo.Stackable then
		for _, v in pairs(tempData.Slots) do
			if v.Item == item then
				if v.Amount < itemInfo.StackCap then
					v.Amount += 1
					tempData.Weight += itemInfo.Weight
					return true
				end
			end
		end
	end

	if #tempData.Slots < data.MaxSlot then
		table.insert(tempData.Slots, {Item = item; Amount = 1})
		tempData.Weight += itemInfo.Weight
		return true
	else
		print("not enough slots")
	end
	return false
end

I tried messing around with the code but got no luck. If anyone could help I’d greatly appreciate it!

1 Like

How would I edit the max weight? 30 is too little for what I’m trying to do.

I have been looking for somehing like this for a long time ago.

Hero Without Cape.

2 Likes

Sorry for late reply, Ive been inactive on the forum, are you sure theres enough room for the weight of what youre trying to pick up? There can be a chance that even if your capacity is 29/30 if you pick up an item with a weight of 2 you wont be able to pick it up

I belive its in the Data Handler, look for the table of default stats

Its good thank you for this it help me alot

Heyo this is really late but how do you make it so you cant equip multiple tools at the same time?

go to replicated storage check the module script named “ItemsInfo”

Amazing system, Great work. But does anyone know why when I change the max Slots to 30 suddenly whenever I pickup an Item I’ve dropped before its goes right to the bottom of the ui?

Edit: This seems to happen with any number other than the default of 16.

I “fixed” it by changing the layout order for the new items slots, still confused why it happened in the first place though

1 Like

Does this system move tools? Or do I have to add that myself

For some reason I can’t add items to ItemsInfo. This is what I’ve done:

["TestItem"] = {
		Name = "TestItem";
		Type = "Resourse";
		Weight = 3;
		Model = ItemModels.TestItem;
		Stackable = true;
		StackCap = 5;
		Droppable = true;
		Desc = "Testing testing 1 2 3"
	}

I’m thinking it has something to do with this:

In the “Inventory” module Inside ServerScriptService:

function Inventory.Get(userId)
	return Datas[userId] and Datas[userId]
end

When you are returning, you are returning two redundant values. It’s giving this warning: “Condition has already been set at column 9”

I could be wrong though.

the system is unable to pick up dropped items after dropping them. i think it adds it, but it doesnt seem to put the slot in

1 Like

after experminating with it, if i put the Inventory.AddItem line twice, it works fine, but picks up 2 for a normal item

This could be it? I believe it is spelled “Resource” instead of what you put. Again this is just something I noticed and may or may not be breaking it. :man_shrugging: