How would I make an inventory limit system?

Hello, Developers!

I’m currently creating a game that will hopefully use a system that forces the player to only be able to hold 1 or 2 items in their inventory/character using ProximityPrompts to pick up the tools.

The goal is to only allow the player to pick up the 1 or 2 items, but if they’re at the max, the next item they attempt to pick up will simply NOT be picked up. I will figure out how to warn the player that they’ve maxed out on their item pickup.

If someone could help me with this, that would be awesome!

Best Regards,
killed.

1 Like

put player as a variable of the player that you want to limit.

for i, v in pairs(player.Backpack:GetChildren()) do
     if i > 2 then
	v:Destroy();     	
     end
end;

player.Backpack.ChildAdded:Connect(function()
	for i, v in pairs(player.Backpack:GetChildren()) do
     		if i > 2 then
			v:Destroy();     	
     		end
	end;
end);
``` sure you could make this code better but i didnt really feel like it
3 Likes

I’ve figured out a solution, thank you, @mxrshxdow, for your reply. Your help allowed me to figure out the problem. Thank you again!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.