Inventory glitches in and out

My inventory glitches in and out

Hi, whenever I enter the fighting room in my game my inventory seems to glitch in and out when I equip a tool. Can anyone help me fix this?

Sword Room Script

--[ SERVICES ]--

local RS = game:GetService('ReplicatedStorage') -- Replicated

--[ LOCALS ]--

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')
local WEAPON = game.ReplicatedStorage['Sword']

--[ FUNCTIONS ]--

HumanoidRootPart.Touched:Connect(function(newPart)
	if newPart:IsDescendantOf(Areas) and newPart.Name == 'Main' and TOUCHING == nil then
		TOUCHING = newPart
		if GotSword == false then
			local item = RS:WaitForChild(WEAPON.Name)
			if item then
				RemoteEvent:FireServer('steppedOn',item)
			end
			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
	local item = Character:FindFirstChild(WEAPON.Name)
	local item2 = Player.Backpack:FindFirstChild(WEAPON.Name)
	if item or item2 then
		RemoteEvent:FireServer('steppedOff',item or item2)
	end
	TOUCHING = nil
	GotSword = false
end)

Please Help…

Uploading: 2022-07-02 14-43-53.mp4…