Cloning tool not working

local Tool = game.ReplicatedStorage.Tools.Gun:clone()
Tool.Parent = game.Players.LocalPlayer.Backpack

In the Output it shows up with…
Workspace.TPTest:3: attempt to index nil with ‘Backpack’

Please Help

LargeHotDogs13

game.Players.LocalPlayer is not defined in server scripts.

Consider using the “.PlayerAdded” event instead, such as in the following.

game.Players.PlayerAdded:Connect(function(player)
	local Tool = game.ReplicatedStorage.Tools.Gun:Clone()
	Tool.Parent = player.Backpack
end)
1 Like