Does anyone know if there is like a Core script or something Which limits the BackPack space, and how I could get it. If that isnt an Option What other simple way can I Limit BackPack storage space to a Certain Number (Preferably using a NumValue)
Iām pretty sure Roblox does not limit the backpack; or it just does to a massive number (not too sure).
But, you can use the ChildAdded
event on the backpack and get rid of the tool if it exceedes the limit. Why use a NumberValue
, though? The number of tools allowed can only be an integer, so an IntValue
might be better, or just using it in the script.
local maxTools = 5 --maximum tools
local backpack = player.Backpack
local function check(child:Instance)
if #backpack:GetChildren() >= maxTools then
child:Destroy()
end
end
backpack.ChildAdded:Connect(check)
Im trying to base the backpack size of a playerstat so it can be upgraded and saved. i also dont wanna completely delete the tool since other players have a chance of picking it up instead so i think just changing the handle name would work right?
The tool would still exist in the backpack if you changed the handle name. You could parent it to the Workspace to make it drop if you want, and then you can use my script and change the maxTools
variable to the NumberValue
instance (NOT its value). Then, change the comparison in the statement:
local maxTools = --path to your number value here
local backpack = player.Backpack
local function check(child:Instance)
if #backpack:GetChildren() >= maxTools.Value then
child.Parent = workspace
end
end
backpack.ChildAdded:Connect(check)
Thank you i will use this for my script right now