Lag when am item uneqquiped

i have a sword tool and when i unequip it it lags

image:
image
PS they are cancollide true,cantouch false and the script is

local Players = game:GetService("Players")
local tool = script.Parent
local handle = tool.Handle
local grip = handle:WaitForChild("Grip")
local swing = tool:WaitForChild("usetool")
tool.Grip = grip.CFrame
local hits = {}
local function onTouch(partOther)
	if tool:GetAttribute("candodamage") == true then
		local hp = partOther:GetAttribute("health")
		if not hp then return end
		if hp > 0 then
			local mobid = partOther:GetAttribute("mobid")
			if hits[mobid] then return end
			partOther:SetAttribute("health",hp - 350)
			hits[mobid] = true
		end
	end
end



local function swordswing()
	local Character = tool.Parent
	local Humanoid = Character:WaitForChild("Humanoid")
	local Animator = Humanoid:WaitForChild("Animator")
	local anim = tool:WaitForChild("slashanim")
	local slash = Animator:LoadAnimation(anim)

	slash:Play()
	tool:SetAttribute("candodamage",true)
	tool.Enabled = false
	wait(0.5)
	tool:SetAttribute("candodamage",false)
	tool.Enabled = true
	hits = {}
end


swing.OnServerEvent:Connect(swordswing)
tool.Handle.Touched:Connect(onTouch)

local script

local tool = script.Parent
local swing = tool:WaitForChild("usetool")

local function onActivated()
	if tool.Enabled == true then
		local character = tool.Parent
		local humanoid = character:FindFirstChildOfClass("Humanoid")
		if humanoid == nil then
			return
		end

		local targetPoint = humanoid.TargetPoint
		swing:FireServer(targetPoint)
	end
end	
tool.Activated:Connect(onActivated)

In what way does it lag? Does it take a long time to unequip? Does it cause the game to freeze? Does it cause other objects to lag in some way?

The code looks fine.

ok video
robloxapp-20220313-1840264.wmv (6.7 MB)