I'm having a bit of trouble attempting to make this function reusable. Hopefully somebody can help me.

Whatever this is called:

repeat wait(0.1) until Player.Character.LowerTorso.Orientation == Player.Character.HumanoidRootPart.Orientation + Vector3.new(10.38,0,0) do
print 'idle start'
		wait(1)
		if Player.Character.LowerTorso.Orientation == Player.Character.HumanoidRootPart.Orientation + Vector3.new(10.38,0,0) == false then return
			elseif Player.Character.LowerTorso.Orientation == Player.Character.HumanoidRootPart.Orientation + Vector3.new(10.38,0,0) == true then
		print 'Idle'
		wait(0.01)
		script.Parent.Folder.IdleWallEvent:FireServer(Player)
	end
end

Function:

local function wallcreate(Player)
local Wall
local success, err = pcall(function()
  Wall = game:GetService("InsertService"):LoadAsset(2096107433)
end)
if success then
  Wall.Parent = workspace
  print("successfully inserted Wall")
else
  warn("unable to insert Wall because " .. err)
end
local Player = game.Players.LocalPlayer
local wall = game.Workspace.Model.SmoothBlockModel
 	wall.CanCollide = false
	wall.Anchored = true
	wall.Transparency = 0
	wait(0.1)
	wall.Orientation = Player.Character.HumanoidRootPart.Orientation
	wall.Position = Player.Character.LowerTorso.Position + Vector3.new(-0.051, 5.548, 2.177)
	wall.Transparency = 0
	
	local yes = Instance.new("Part")
	yes.Name = "yes"
	yes.Parent = game.Workspace
	yes.CanCollide = false
	yes.Anchored = true
	yes.Position = Player.Character.LowerTorso.Position
	yes.Transparency = 0
	
	repeat wait(0.5) until Player.Character.LowerTorso.CFrame == yes.CFrame == false do
			Wall:Destroy()
			print 'Wall Destroyed'
			yes:Destroy()
			print 'Almost Done'
		end
	end

script.Parent.Folder.IdleWallEvent.OnServerEvent:connect(wallcreate)