Whenever you go on the arena it keeps giving you the sword, deleting it, giving it back, over and over and I don't know why because I added checks if the player is still touching the arena and if they still have the sword.
Doesn't print any errors or anything
Server script:
local ReplicatedStorage = game:GetService("ReplicatedStorage") local ServerStorage = game:GetService("ServerStorage") local TouchEvent = ReplicatedStorage:WaitForChild("ToolEvent") local Areas = workspace:FindFirstChild("SwordFightZone") game.Players.PlayerAdded:Connect(function(Player) local Folder = Instance.new('Folder') Folder.Name = Player.Name.. "'s Tools" Folder.Parent = game.ReplicatedStorage end) local function FireRemote(plr,val) local itemname = plr:WaitForChild("Sword") local item = ReplicatedStorage:WaitForChild("Swords"):FindFirstChild(itemname.Value) if val == 'steppedOn' then local Character = plr.Character local hasSword = false for i,v in pairs(Character:GetChildren()) do if v:IsA("Tool") and v.Name == item.Name then hasSword = true end end for i,v in pairs(plr:WaitForChild("Backpack"):GetChildren()) do if v:IsA("Tool") and v.Name == item.Name then hasSword = true end end local stillTouching = false for _,v in pairs(Character:FindFirstChild("HumanoidRootPart"):GetTouchingParts()) do if v:IsDescendantOf(Areas) and v.Name == "Main" then stillTouching = true end end if hasSword or (stillTouching and hasSword) then return end for i,v in pairs(Character:GetChildren()) do if v:IsA('Tool') then v.Parent = game.ReplicatedStorage[plr.Name.. "'s Tools"] end end for i,v in pairs(plr.Backpack:GetChildren()) do if v.Name ~= item.Name then if game.ReplicatedStorage[plr.Name.. "'s Tools"] then v.Parent = game.ReplicatedStorage[plr.Name.. "'s Tools"] end end end local NewWEAPON = item:Clone() NewWEAPON.Parent = plr.Backpack Character.Humanoid:EquipTool(NewWEAPON) Character:FindFirstChild("Humanoid").MaxHealth = 100 Character:FindFirstChild("Humanoid").WalkSpeed = 16 Character:FindFirstChild("Head"):FindFirstChild("Rank"):FindFirstChild("Frame"):FindFirstChild("Rank").Text = "Kills: "..plr:FindFirstChild("Kills").Value Character:FindFirstChild("Sprint").Enabled = false elseif val == 'steppedOff' then local Character = plr.Character local stillTouching = false for _,v in pairs(Character:FindFirstChild("HumanoidRootPart"):GetTouchingParts()) do if v:IsDescendantOf(Areas) and v.Name == "Main" then stillTouching = true end end for i,v in pairs(Areas:GetChildren()) do if v:IsA("BasePart") then for _, t in pairs(v:GetTouchingParts()) do if t.Name == "HumanoidRootPart" then if t.Parent.Name == plr.Name then stillTouching = true end end end end end if stillTouching then return end for i,v in pairs(Character:GetChildren()) do if v then if v:IsA('Tool') then if v.Name == item.Name then v:Destroy() end end end end for i,v in pairs(plr.Backpack:GetChildren()) do if v then if v:IsA('Tool') then if v.Name == item.Name then v:Destroy() end end end end for i,tool in pairs(game.ReplicatedStorage[plr.Name.. "'s Tools"]:GetChildren()) do -- now we get all our tools back tool.Parent = plr.Backpack end Character:FindFirstChild("Humanoid").MaxHealth = math.huge Character:FindFirstChild("Humanoid").Health = math.huge Character:FindFirstChild("Head"):FindFirstChild("Rank"):FindFirstChild("Frame"):FindFirstChild("Rank").Text = "Level: "..plr:FindFirstChild("Level").Value Character:FindFirstChild("Sprint").Enabled = true end end TouchEvent.OnServerEvent:Connect(FireRemote) game.Players.PlayerRemoving:Connect(function(Player) if game.ReplicatedStorage:FindFirstChild(Player.Name.. "'s Tools") then game.ReplicatedStorage:FindFirstChild(Player.Name.. "'s Tools"):Destroy() end end)
Local Script:
local RS = game:GetService('ReplicatedStorage') local GotSword = false TOUCHING = nil local Player = game.Players.LocalPlayer local Character = Player.Character or Player.CharacterAdded:Wait() local Humanoid = Character.Humanoid local Areas = workspace.SwordFightZone local HumanoidRootPart = Character:WaitForChild('HumanoidRootPart') local RemoteEvent = RS:WaitForChild('ToolEvent') HumanoidRootPart.Touched:Connect(function(newPart) local hasSword = false for i,v in pairs(Character:GetChildren()) do if v:IsA("Tool") and v.Name == Player:FindFirstChild("Sword").Value then hasSword = true end end for i,v in pairs(Player:WaitForChild("Backpack"):GetChildren()) do if v:IsA("Tool") and v.Name == Player:FindFirstChild("Sword").Value then hasSword = true end end if newPart:IsDescendantOf(Areas) and newPart.Name == 'Main' and TOUCHING == nil and not hasSword and not GotSword then TOUCHING = newPart if GotSword == false then RemoteEvent:FireServer('steppedOn') GotSword = true end end end) HumanoidRootPart.TouchEnded:Connect(function(newPart) for _, part in pairs(HumanoidRootPart:GetTouchingParts()) do if part == TOUCHING and newPart.Name == 'Main' then return end end RemoteEvent:FireServer('steppedOff') TOUCHING = nil GotSword = false end)