Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Limited backpack ?

Asked by 8 years ago

How can i limit the player backpack to two tools at a time ?

2 answers

Log in to vote
0
Answered by 8 years ago

There are many ways to do this. First of all, you could index them all and if i>2 then all you would have to do is remove a tool or more if needed. You could also just have conditional statements pretty much count them out 1 by 1 and if there is more then 2 then you could just have it remove some.

Ad
Log in to vote
0
Answered by 8 years ago

Bind a ChildAdded event to the Backpack.

ex:

local Backpack = game.Players.LocalPlayer.Backpack
Backpack.ChildAdded:connect(
function(child)
local Items = #Backpack:GetChildren()
print("There are now "..tostring(Items).." in "..game.Players.LocalPlayer.Name.."'s backpack!")
if Items > 2 then
-- Code here!
end
end
)

Answer this question