Hello everyone, I was wondering if limiting the hotbar is possible.
I want it so I can only put 5 items in here
Thank you in advance.
Hello everyone, I was wondering if limiting the hotbar is possible.
I want it so I can only put 5 items in here
Thank you in advance.
The hotbar only shows what tools are in your backpack folder, if you want it so that you can only have 5 tools at a time you should check how much tools are in a player’s backpack whenever you try to give them a tool, like
local player = --your player
local tool = --your tool
if #player.Backpack:GetChildren() < 5 then
--give your tool to the player
else
print("5 tools inside backpack, cannot give")
end
The hotbar can store only 10 tools and the rest will be in your inventory, you can access it by pressing " ~ “. but I want it so that it can only store 5 items (in the hotbar) then the rest is hidden in the inventory (” ~ " key).
As far as i remember the hotbar gui is a coregui and i don’t really tackle with manipulating those, so the only method i can think is to have a seperate folder named “Inventory” and every other hidden tool goes there
So I would have to make my own inventory gui?
It isn’t possible to manipulate the CoreGui whatsoever, regular Roblox game scripts can’t change values in it. The only way I can think of to achieve this would be coding your own hotbar and disabling the CoreGui hotbar.
If you need to be pointed in the right direction, you could create two Folders, one of your hotbar and one for a separate inventory screen. You could code in something logical such as checking if the hotbar folder has a certain amount of elements in it, and if it does you’d put the tool in the separate inventory screen Folder. You could then display the tools to the corresponding screen depending on which folder they are in. Obviously it’s more complicated then that, but that should help you out slightly if you don’t know where to start.
Thank you, I think I know what I have to do now.
You could restrict the player’s backpack to 5 tools.
local players = game:GetService("Players")
players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local backpack = character:WaitForChild("Backpack")
backpack.ChildAdded:Connect(function(child)
local toolCount = 0
for _, tool in ipairs(backpack:GetChildren()) do
if tool:IsA("Tool") then
toolCount += 1
end
end
if toolCount > 5 then
child:Destroy()
end
end)
end)
end)