I am currently developing an inventory system, that shouldn’t cover alot of the player’s fov (invisible). The results should look similar to the ones you see in alot of shooter games. For that, I use folders in the replicated storage, that have the player name they belong to. They also contain a folder for the primary, and one for the secondary weapon, and two remote events, one for equiping the primary, and one for equipping the secondary.
The issue is, the code won’t parent the weapon to the player, and even if, the tool probably won’t work.
Here are the most important parts of the code:
Equip_WeaponData (Serverscript in a screengui):
wait()
--//Variables for Loadout lol
local plrname = script.Parent.Parent.Parent.Name
local LoadOutPlr = game.ReplicatedStorage[plrname]
local LoadOutFolder = LoadOutPlr.LoadOutFolder
local Pr = LoadOutFolder.Primaries
local Sr = LoadOutFolder.Secondaries
--//Now ill get to the serverside stuff ill need
local Character = workspace[plrname]
local Humanoid = Character:WaitForChild("Humanoid")
local PrWeapon = Pr:FindFirstChildOfClass("Tool")
local SrWeapon = Sr:FindFirstChildOfClass("Tool")
--//Creating some events and stuff
local Pequip = Instance.new("RemoteEvent", LoadOutPlr)
local Sequip = Instance.new("RemoteEvent", LoadOutPlr)
--//Naming the events so the client script that detects if the player presses 1 or 2 can find the events
Pequip.Name = "PrimaryEquip"
Sequip.Name = "SecondaryEquip"
----------------------------------------------
----------------------------------------------
--//Now we'll check for the events, main code
Pequip.OnServerEvent:Connect(function()
local Tool = Character:FindFirstChildOfClass("Tool")
if Tool and Humanoid then
Tool:Destroy() --force unequips the tool
Humanoid:EquipTool(PrWeapon) --equips new tool
end
end)
Sequip.OnServerEvent:Connect(function()
local Tool = Character:FindFirstChildOfClass("Tool")
if Tool and Humanoid then
Tool:Destroy()
Humanoid:EquipTool(SrWeapon)
end
end)
Equip_WeaponClient (Localscript in screengui):
repeat wait() until script.Parent.Enabled == false --player cant equip a gun, unless he already deployed
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
--//locate the name of the player
local plrname = script.Parent.Parent.Name
--//the events we created in "Equip_WeaponData"
local Pequip = game.ReplicatedStorage:WaitForChild(plrname):WaitForChild("PrimaryEquip")
local Sequip = game.ReplicatedStorage:WaitForChild(plrname):WaitForChild("SecondaryEquip")
--//now we'll get the user input service rolling
local Uis = game:GetService("UserInputService")
----------------------------------------------
----------------------------------------------
Uis.InputBegan:Connect(function(io, p)
if io.KeyCode == Enum.KeyCode.One then --if the player presses 1, we'll fire the remote event
Pequip:FireServer()
end
if io.KeyCode == Enum.KeyCode.Two then --the player also might want to equip a secondary, so we also make a code for that
Sequip:FireServer()
end
end)
If you need more code, like the code that creates the folders, then just tell me and I’ll happily provide more. Like I said, the tools won’t equip.
I tried rewriting the code multiple times in multiple services. The output doesnt say anything.
Also I’ve never done a system that is too similiar to this, so I am not very experienced in coding custom inventory systems yet.

