Tool not equipping to backpack

I’ve looked through several topics and I haven’t been able to make this work.

My goal is to make the Tool equip to the current player’s backpack when the Gui button is pressed, quite simple.

Code:

local Prompt = game.Workspace.NPCRSIX.ProximityPrompt
local ScreenGui = game.Players.LocalPlayer.PlayerGui.ScreenGui
local Button = game.Players.LocalPlayer.PlayerGui.ScreenGui.TextButton

Prompt.Triggered:Connect(function()
	ScreenGui.Enabled = true
end)

Button.MouseButton1Click:Connect(function()
	local plr = game.Players.LocalPlayer
	local backpack = plr:WaitForChild('Backpack')
	local Shotgun = game:GetService('ServerStorage'):WaitForChild('Shotgun')
	Shotgun:Clone().Parent = plr.backpack
end)

Error:

Infinite yield possible on 'ServerStorage:WaitForChild("Shotgun")'

Don’t really understand as there is only 1 so it can easily locate the child, I’ve tried different locating as well.

Anything inside of ServerStorage is not replicated to clients. You would need to place your Tool in another location, such as ReplicatedStorage.

1 Like