tool.Parent keeps on equaling nil

I have some code that assigns a tool from serverstorage to the player’s backpack. Here is the script in serverscriptservice:

game.ReplicatedStorage.GiveTool.OnServerEvent:Connect(function(player)
	local toolToGive = game.ServerStorage.Antibody
	local toolClone = toolToGive:Clone()
	toolClone.Parent = player.Backpack -- this is the problem
end)

Upon examining the debugger’s watch and call stack I found something interesting: the tools’s parent is actually nil (see image below)


I find this weird as I assigned the tool’s Parent to the player’s Backpack, which clearly exists because I have seen some posts saying maybe the player’s backpack has not loaded yet. How do I fix this issue? FYI: I don’t want to use the player:CharacterAdded() method because the script is actually part of a remote event, so the client-side presses a button to equip a tool (which fires the remote event) and it gets cloned into the player’s backpack.

Do you have a place file available?

Not at the moment, sorry its part of a bigger project for my client, which they probably don’t want it disclosed.

Thats fine.

Just try:

local server_storage = game:GetService("ServerStorage")

local tool_to_clone = server_storage:WaitForChild("Antibody")
game.ReplicatedStorage.GiveTool.OnServerEvent:Connect(function(player)
	local backpack = player:WaitForChild("Backpack")
	tool_to_clone:Clone().Parent = backpack
end)

Can we see the remote event that was fired from the client

I actually found the solution, I actually had to parent the tool to the player’s starter gear:

game.ReplicatedStorage.GiveTool.OnServerEvent:Connect(function(player)
	local toolToGive = game.ServerStorage:WaitForChild("Antibody")
	local toolClone = toolToGive:Clone()
	toolClone.Parent = player:WaitForChild("StarterGear")
end)