Why isn't my sword disappearing when the round ends?

What do you want to achieve? I’m making a simple round based sword fighting game for a project.

  1. What is the issue? When the round starts, I get my sword, but when the round ends the sword only dissapears if the sword is unequipped.

  2. What solutions have you tried so far? None so far.


hasStarted.Changed:Connect(function()
	if hasStarted.Value == true then
		for _, player in pairs(game.Players:GetChildren()) do
			local char = player.Character
			char.HumanoidRootPart.CFrame = GameSpawn.CFrame
			
			local sword = game.ServerStorage:FindFirstChild("ClassicSword")
			local copy = sword:Clone()
			copy.Parent = player.Backpack
		end
	else 
			for _, player in pairs(game.Players:GetChildren()) do
				local char = player.Character
			char.HumanoidRootPart.CFrame = LobbySpawn.CFrame
			
			player.Backpack.ClassicSword:Destroy()
			
		end	
	end
end)

Looking for a response! :grinning:

This is because tools get parented to the character when they equip it. When you want to destroy the sword, check if it’s in the character or the player by using :FindFirstChild() in a if statement.

1 Like

Hi. When player has equipped the tool then the tool is not in Backpack but in the player’s character (player-character.sword).

hasStarted.Changed:Connect(function()
	if hasStarted.Value == true then
		for _, player in pairs(game.Players:GetChildren()) do
			local char = player.Character
			char.HumanoidRootPart.CFrame = GameSpawn.CFrame
			
			local sword = game.ServerStorage:FindFirstChild("ClassicSword")
			local copy = sword:Clone()
			copy.Parent = player.Backpack
		end
	else 
			for _, player in pairs(game.Players:GetChildren()) do
				local char = player.Character
			char.HumanoidRootPart.CFrame = LobbySpawn.CFrame
			
           local sword = player.Character.ClassicSword or player.Backpack.ClassicSword
			sword:Destroy()
			
		end	
	end
end)
1 Like