Hi, I'm trying to make my own custom weapon slots similar to the regular backpack. However, whenever weapons are picked up it just shows the classic backpack lots popping up. How would I hide those inventory slots without disabling the backpack completely? I disabled it but then I couldn't use tools anymore.
You will have to set up a Key Bind to the number keys and then fire a RemoteEvent with the key number.
1 | -- This part is pseudo code... I dont feel like creating working client code. |
2 | function OnKeyPress(key) |
3 | if key = = number then |
4 | game:GetService( "ReplicatedStorage" ).EquipTool:FireServer(number) |
5 | end |
6 | end |
On the server side you can handle it kind of like this:
01 | local currentEquipped = { } |
02 | game:GetService( "ReplicatedStorage" ).EquipTool.OnServerEvent:connect( function (player, slot) |
03 | local hum = workspace:WaitForChild(player.Name).Humanoid |
04 | if player:WaitForChild( "Backpack" ):GetChildren() [ slot ] then |
05 | if currentEquipped [ player.Name ] ~ = slot then |
06 | hum:UnequipTools() |
07 | hum:EquipTool(player.Backpack:GetChildren() [ slot ] ) |
08 | currentEquipped [ player.Name ] = slot |
09 | else |
10 | hum:UnequipTools() |
11 | currentEquipped [ player.Name ] = nil |
12 | end |
13 | else |
14 | hum:UnequipTools() |
15 | currentEquipped [ player.Name ] = nil |
16 | end |
17 | end ) |
1 | local StarterGui = game:GetService( 'StarterGui' ) |
2 | StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false ) |
However, I have been able to get this to work at all with FE.