Hello guys!
Today I have a question: How can I put a tool limit on the Roblox backpack
For example, I want the Roblox backpack to only have 2 tools in the toolbar and the rest in the inventory!
Well thank you!
Hello guys!
Today I have a question: How can I put a tool limit on the Roblox backpack
For example, I want the Roblox backpack to only have 2 tools in the toolbar and the rest in the inventory!
Well thank you!
I donât believe you can do this with the standard Roblox backpack. I think youâre going to have to make a custom inventory to do this.
I would say use an Int value and make the value the limit of tools you want and then use a GetChildren() variable with the backpack. Sort of like this if you struggle to understand what I mean
local Players = game:GetService("Players")
local replicatedStorage = game:GetService("ReplicatedStorage")
local plr = Players.LocalPlayer
local bacpack = plr:WaitForChild("Backpack"):GetChildren()
local intValue = replicatedStorage.ToolLimit
if #backpack > intValue.Value then
#backpack:Destroy()
end)
But the issue is, at the âif #backpack > intValue.Value then #backpack:Destroy() end)â part, it destroys every child.
I tried this in a script in one of my games:
local numberOfFrames = math.random(2, #mainFrame:GetChildren())
numberOfFrames:Destroy()
end)
But that didnât work. It gave me an error saying âAttempt to index number with âDestroyââ because I tried destroying a number.
Give me a day or two to attempt to find a solution!
This should work. I havenât tested it, But I remade it from one of my other projects. @antolol7350
for _, p in pairs(game.Players:GetChildren()) do
local backpack = p:WaitForChild("Backpack")
local BackpackItems = backpack:GetChildren() --Table--
local ToolLimit = game.ServerStorage.ToolLimit --Int Value--
backpack.ChildAdded:Connect(function(instance)
if #BackpackItems > ToolLimit.Value then
instance:Destroy() --Destroys Most Recent Item added to inventory/backpack--
end
end)
end)
(This goes in the server as well) so it cant be exploited
You might also want to add a PlayerLeft to this, To optimize the servers more by disconnecting the ChildAdded
Function
@AmoraFolf @FentTamer I may be misunderstanding the OPâs question but didnât he want the items to be put into the inventory and not just destroyed?
The inventory is the backpack idk what you mean.
itâs she but ok yeah I want it to be in the inventory like the GUI
Ok well the in game gui is still apart of backpack, So we canât specifically set a tool limit and move it to the inventory. the Inventory in game is just extra spaces. (11, 12, 13, etc.)
slots
I am decently sure we canât switch the slots to something that doesnât exist. Deleting it would be the only solution. Or a custom inventory gui instead of using backpack.
They want the item to be moved out of the toolbar into their inventory. The toolbar is the tools you see in the bar and the inventory is shown when you press ~.
One of the ideas I had regarding the topic, was to create fake tools with blank images representing empty spots. Although this gets way too complicated in a small amount of time and the user is still able to manually move their tools(unless you keep refreshing them which will cause client-sided lag). I think the action of moving the UI element of a tool cannot be forked, although if anyone has a hacky solution to this please provide it in the replies.
I think this should be a good suggestion for Roblox no?
Like Katrist said, I donât believe this is possible without a custom UI. But that shouldnât be very difficult to reproduce at all.
Hereâs Robloxâs backpack if you want the same UI:
Roblox Backpack Gui.rbxm (15.7 KB)
(Note that it wonât be visible by default as this was copied with an empty backpack. Also includes no scripts.)
oh well thank you i will see what i can do with that!