My filesystem is generating this error

Hello! I am creating a Filesystem on Roblox, however, I get this error when I go to the previous directory (When I click on the Back button):

local CurrentDirectory = game:GetService("ReplicatedStorage")

local function Check()
	for _, Stuff in pairs(script.Parent:GetChildren()) do
		if Stuff:IsA("TextButton") then
			Stuff:Destroy()
		end
	end
	local UpDown = 0
	for _, RepStor in pairs(CurrentDirectory:GetChildren()) do
		local TextLabel = script.Parent.Parent.Parent.Parent.TextLabel:Clone()
		TextLabel.Text = RepStor.Name
		TextLabel.Visible = true
		TextLabel.Parent = script.Parent
		UpDown += TextLabel.Size.Y.Offset
		script.Parent.CanvasSize = UDim2.new(0, 0, 0, UpDown)
		TextLabel.MouseButton1Click:Connect(function()
			CurrentDirectory = CurrentDirectory[TextLabel.Text]
			Check()
		end)
		script.Parent.Parent.Parent.Title.Back.MouseButton1Click:Connect(function()
			CurrentDirectory = CurrentDirectory.Parent -- This is where it errors. Idk why it doesnt like it when I do this.
			Check()
		end)
	end
end

game:GetService("ReplicatedStorage").ChildAdded:Connect(Check)
game:GetService("ReplicatedStorage").ChildRemoved:Connect(Check)

Check()

If you can help me, that would be really kind of you.
Thank you for your time.

Try printing CurrentDirectory above the line where it errors to make sure CurrentDirectory exists