Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to make sure no one gets more than 11 items in inventory?

local max = math.max(1,2,3,4,5,6,7,8,9,10,11)
local plr = game.Players.LocalPlayer
local pack = plr.Backpack:GetChildren()
local replicatedstorage = game:GetServer("ReplicatedStorage")

if pack.max then
print("This player has to many items")
pack:Destroy()
replicatedstorage.RedFoil:Clone()

else
print ("This player is under the limit")
end

I want the player to only have one item, and to destroy all but one of the swords in the inventory, which will clone again. I have a shop with multiple swords and I want to delete all other swords so the player only have the one they chose.

I dont get any errors but it doesnt print.

1 answer

Just check the amount like this:

local plr = game.Players.LocalPlayer
local pack = plr.Backpack:GetChildren()
local replicatedstorage = game:GetServer("ReplicatedStorage")

if #pack >= 11 then
	print("This player has to many items")
	pack:Destroy()
	replicatedstorage.RedFoil:Clone()
else
	print ("This player is under the limit")
end

This discussion is preserved as it was. New answers, comments, and votes are closed.