How to get tools after death after StarterGear being deprecated?

The title basically explains it all, this code isn’t working at all:

local tool = game:GetService("ReplicatedStorage").PrimaryWeapon.Mace:Clone()

local tool2 = tool:Clone()
tool2.Parent = game.Players.LocalPlayer.StarterGear
tool.Parent = game.Players.LocalPlayer.Backpack
1 Like

First, this isn’t going to be replicated to the server, you’ll want to have a LocalScript in StarterCharacterScripts that fires a RemoteEvent to the server that will give the person the tool.

I made something as an example, here.

LocalScript

local RemoteEvent = game:GetService("ReplicatedStorage"):FindFirstChild("RemoteEvent")


RemoteEvent:FireServer("Club")

Server Script

local RemoteEvent = game:GetService("ReplicatedStorage"):FindFirstChild("RemoteEvent")


RemoteEvent.OnServerEvent:Connect(function(Player, ToolName)
	local ToolClone = game:GetService("ReplicatedStorage").PathToTool[ToolName]:Clone()
	ToolClone.Parent = Player.Backpack
end)

This method will ensure that all players can see the other players weapons rather than being on the client, and the server will detect that as well.

well the example i showed you is from a server script, and I want it so that when the player dies, they still spawn back with the tool

That’s why it isn’t working, you’re using game.Players.LocalPlayer in a ServerScript, which can only be accessed from a Local Script

If you wish to only do it on the server, there’s this also- which uses the PlayerAdded event

game.Players.PlayerAdded:Connect(function(Player)
	local ToolClone = game:GetService("ReplicatedStorage").PathToTool:FindFirstChild("Club"):Clone()

	Player.CharacterAdded:Connect(function(Character)
		ToolClone.Parent = Player.Backpack
	end)
end)```