Why doesn't The "Tool" destroy when player position is greater than the Magnitude?

Hello. I am trying to make a sword arena but when the character leaves the arena or the players position is is greater than the magnitude 30, It wont destroy the sword.

local Part = workspace.PvP.PvPZ
local Tool = game.Lighting.Storage:WaitForChild("LinkedSword")

while true do
	for _, Player in pairs(game.Players:GetPlayers()) do
		local Character = Player.Character
		if Character and Player.Backpack:FindFirstChild("LinkedSword") == nil and Character:FindFirstChild("LinkedSword") == nil then
			if (Character.HumanoidRootPart.Position - Part.Position).Magnitude < 30 then
				local Clone = Tool:Clone()
				Clone.Parent = Player.Backpack
				if (Character.HumanoidRootPart.Position - Part.Position).Magnitude > 30 and Player.Backpack:FindFirstChild("LinkedSword") then
					Player.Backpack.LinkedSword:Destroy()
				else
					if (Character.HumanoidRootPart.Position - Part.Position).Magnitude > 30 and Character:FindFirstChild("LinkedSword") then
						Character.LinkedSword:Destroy()
						end
				end
			end
		end
	end
	wait(0.001)
end

If you see any other errors with this script, please tell me. Thanks!

The destroy check is nested inside the <30 condition so it is never true. Place it below the if statement giving the sword.

I don’t mean to inturrupt but I dont understand too much. can you give abit more detail? Thank you very mouch! :slight_smile: I undersand that it wont work because its nested but I dont understand the placement.

local Part = workspace.PvP.PvPZ
local Tool = game.Lighting.Storage:WaitForChild("LinkedSword")

while true do
	for _, Player in pairs(game.Players:GetPlayers()) do
		local Character = Player.Character
		if Character and Player.Backpack:FindFirstChild("LinkedSword") == nil and Character:FindFirstChild("LinkedSword") == nil then
			if (Character.HumanoidRootPart.Position - Part.Position).Magnitude < 30 then
				local Clone = Tool:Clone()
				Clone.Parent = Player.Backpack
			end

				if (Character.HumanoidRootPart.Position - Part.Position).Magnitude > 30 and Player.Backpack:FindFirstChild("LinkedSword") then
					Player.Backpack.LinkedSword:Destroy()
				else
					if (Character.HumanoidRootPart.Position - Part.Position).Magnitude > 30 and Character:FindFirstChild("LinkedSword") then
						Character.LinkedSword:Destroy()
						end
				end

		end
	end
	wait(0.001)
end