Recently, I have been working on a custom inventory system for my game and well, its going good so far, but its just one problem.
Once a player clicks the tool that they want to equip, the player doesn’t even equip it at all.
Then, this is the code that will try and make the player equip the tool
(remote event, server script):
local givetoolevent = game:GetService("ReplicatedStorage").giveTool local tools = game:GetService("ServerStorage"):WaitForChild("tools") local addedtools = game.ReplicatedStorage:WaitForChild("addedTools") givetoolevent.OnServerEvent:Connect(function(player, toolName) -- Guarding if tools:FindFirstChild(toolName) == nil then warn("No such tool.") return end local tool = tools:FindFirstChild(toolName) print(tool) -- Equip Tool Logic from here. local chr = player.Character or player.CharacterAdded:Wait() local humanoid = chr:WaitForChild("Humanoid") wait() humanoid:EquipTool(tool) end)
I also took inspiration from this topic:
Is it something I am doing wrong? I am really confused on why this is not working, there isn’t any warnings or errors, or anything at all. Any help is appreciated.
I used a Client Script to provide the tool’s name to the server, with this code:
local function equipTool(toolName) local toolModel = tools:FindFirstChild(toolName) if toolModel == nil then return end givetoolevent:FireServer(toolName) end
the “tools” variable in
tools:FindFirstChild(...) is a folder inside of replicated storage, that pretty much stores tools.