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!