Players respawn with gears equipped to the character

(I accidentally posted this before I finished the post, sorry.)

As the title suggests, I have found that upon equipping any Roblox catalog gear and resetting, the player would respawn with it, despite the gear only being parented to the backpack. When resetting without equipping the gear, it would be deleted as expected. This seems only to be a problem with my game, however, I have absolutely no clue what causes it. My code simply parents the clone of a tool to the player’s backpack.

--server
local function shop(player, tool)
	local newtool = tool:Clone()
	newtool.Parent = player.Backpack
end --code is this, but with a couple of checks, unrelated.

remotevent.OnServerEvent:Connect(shop)

--client
remotevent:FireServer(tool) --fired by client from gui

I don’t plan on posting the full code, since it’s unrelated. I’m assuming the issue stems from when the player dies/respawns, but there’s nothing in the code that would affect that. I’m just looking for some clues as to what could be causing this. I do have some scripts which run when the player’s character is added back in, but they don’t have anything to do with the player’s backpack, startergear, etc.

You have to parent it to the Player.StarterGear for them to respawn with the tool. I believe the Roblox equipped gears bypass this somehow on the backend.

Try this instead:

local function shop(player, tool)
	local newtool = tool:Clone()
	newtool.Parent = player.StarterGear
	
	if player.Character then
		local newtool = tool:Clone()
		newtool.Parent = player.Backpack
	end
end

remotevent.OnServerEvent:Connect(shop)
2 Likes

Sorry if I wasn’t being very clear, but my issue is that players are respawning with the tool even though it’s being parented to the backpack.

1 Like

Ohh, sorry for the misunderstanding. I honestly don’t know what could be happening for your game then. Are you sure none of your scripts interfere with the children of the character or anything that could relate to the tools?

1 Like

I’ve checked through all of my scripts that have to do with CharacterAdded and CharacterRemoving, but none of them directly interact with the character’s children or tools.

Since they are respawning with the tool, and we have no clue what’s causing it, I would assume it is a part of Roblox’s gear code. So, to counteract it, when the player dies, manually destroy the tool.

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		char:WaitForChild("Humanoid").Died:Connect(function()
			if char:FindFirstChildOfClass("Tool") then
				char:FindFirstChildOfClass("Tool"):Destroy()
			end
		end)
	end)
end)

This would definitely fix the issue, but I’m still curious about why this occurs. I’ve tested the same thing in a separate game and there were no issues. Though, this does help prevent it for now. Thanks.

You should probably do some digging into the scripts around your game if it has nothing to do with the tools themselves. But, yes, this can prevent it for now.