Player not equipping tool ..?

Hello there!

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.

Edit;

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.

I didn’t know that “humanoid:EquipTool()” existed and maybe that is the problem, on roblox when you equip a tool it will move it from the player’s Backpack and put it into his Character model so you could simply do

-- Equip Tool Logic from here. 

local chr = player.Character or player.CharacterAdded:Wait()

wait() 	
tool.Parent = chr
1 Like

Didn’t think of that. It was really that simple huh?

Thank you for your help.

1 Like

No problem! Also maybe you should clone the tool before putting into the player’s character because instead there would be no tool in the tool’s folder for other players

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.