
Clean The Library script - (Auto Organize books)
- Author
bebraPublished by
Script Description
This Clean The Library script is made for players who want a calmer and more automatic way to organize books during long library cleaning runs. Since the game is built around picking up scattered books, finding the correct shelves, sorting them into the right sections, and cleaning the library as…
This Clean The Library script is made for players who want a calmer and more automatic way to organize books during long library cleaning runs. Since the game is built around picking up scattered books, finding the correct shelves, sorting them into the right sections, and cleaning the library as efficiently as possible, this script focuses on helping players reduce repetitive book placement and keep progress moving steadily. The Auto Clean Library feature is useful when players want to organize books without manually checking every shelf, carrying books back and forth, and repeating the same sorting process for a long time. It can help during solo runs, slower cleanup sessions, or when the library becomes crowded with many unsorted books. Because this version works at slow speed, it is better suited for stable and controlled cleaning rather than aggressive fast farming. This can be useful for players who want the automation to look smoother, avoid rushed movement, and let the script handle book organization more carefully while the library is being cleaned. The script is especially helpful for players who want to focus on overall progress, leaderboard attempts, completion goals, or simply make the cleaning process less tiring. Instead of spending the whole session manually sorting book after book, Auto Clean Library helps keep the library cleanup loop more consistent. Overall, this Clean The Library script is useful for players who want automatic book organization, slower and more stable library cleaning, easier solo progress, and less repetitive manual sorting during long cleanup runs.
This Clean The Library script is made for players who want a calmer and more automatic way to organize books during long library cleaning runs. Since the game is built around picking up scattered books, finding the correct shelves, sorting them into the right sections, and cleaning the library as efficiently as possible, this script focuses on helping players reduce repetitive book placement and keep progress moving steadily. The Auto Clean Library feature is useful when players want to organize books without manually checking every shelf, carrying books back and forth, and repeating the same sorting process for a long time. It can help during solo runs, slower cleanup sessions, or when the library becomes crowded with many unsorted books. Because this version works at slow speed, it is better suited for stable and controlled cleaning rather than aggressive fast farming. This can be useful for players who want the automation to look smoother, avoid rushed movement, and let the script handle book organization more carefully while the library is being cleaned. The script is especially helpful for players who want to focus on overall progress, leaderboard attempts, completion goals, or simply make the cleaning process less tiring. Instead of spending the whole session manually sorting book after book, Auto Clean Library helps keep the library cleanup loop more consistent. Overall, this Clean The Library script is useful for players who want automatic book organization, slower and more stable library cleaning, easier solo progress, and less repetitive manual sorting during long cleanup runs.
Script Functions
1 function- Auto Clean Library (Slow speed)
Script Code
362 lines · 12.68 KB · LuaReview before running. Use scripts responsibly.
1-- Simple Book Organizer with Toggle + Ctrl+LMB Mouse Toggle2local Players = game:GetService("Players")3local ReplicatedStorage = game:GetService("ReplicatedStorage")4local Workspace = game:GetService("Workspace")5local CollectionService = game:GetService("CollectionService")6local UserInputService = game:GetService("UserInputService")78local Settings = {9 Enabled = false,10 FastMode = false,11 MouseLocked = false,12}1314local function isCtrlDown()15 return UserInputService:IsKeyDown(Enum.KeyCode.LeftControl)16 or UserInputService:IsKeyDown(Enum.KeyCode.RightControl)17end1819local function setMouseLocked(locked)20 Settings.MouseLocked = locked21 pcall(function()22 if locked then23 UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter24 UserInputService.MouseIconEnabled = false25 else26 UserInputService.MouseBehavior = Enum.MouseBehavior.Default27 UserInputService.MouseIconEnabled = true28 end29 end)30end3132local function safeCancel(thread)33 if thread then34 pcall(task.cancel, thread)35 end36end3738local function CreateUI()39 local screenGui = Instance.new("ScreenGui")40 screenGui.Name = "BookOrganizerGUI"41 screenGui.ResetOnSpawn = false42 screenGui.Parent = Players.LocalPlayer:WaitForChild("PlayerGui")4344 local mainFrame = Instance.new("Frame")45 mainFrame.Size = UDim2.new(0, 300, 0, 150)46 mainFrame.Position = UDim2.new(0.5, -150, 0.5, -75)47 mainFrame.BackgroundColor3 = Color3.fromRGB(25, 25, 35)48 mainFrame.BackgroundTransparency = 0.0549 mainFrame.BorderSizePixel = 050 mainFrame.ClipsDescendants = true51 mainFrame.Parent = screenGui5253 local titleBar = Instance.new("Frame")54 titleBar.Size = UDim2.new(1, 0, 0, 35)55 titleBar.BackgroundColor3 = Color3.fromRGB(50, 50, 70)56 titleBar.BackgroundTransparency = 0.357 titleBar.BorderSizePixel = 058 titleBar.Parent = mainFrame5960 local title = Instance.new("TextLabel")61 title.Size = UDim2.new(1, -35, 1, 0)62 title.BackgroundTransparency = 163 title.Text = "📚 Book Organizer"64 title.TextColor3 = Color3.fromRGB(255, 255, 255)65 title.TextSize = 1666 title.Font = Enum.Font.GothamBold67 title.Parent = titleBar6869 local closeBtn = Instance.new("TextButton")70 closeBtn.Size = UDim2.new(0, 25, 0, 25)71 closeBtn.Position = UDim2.new(1, -30, 0, 5)72 closeBtn.BackgroundColor3 = Color3.fromRGB(200, 50, 50)73 closeBtn.BackgroundTransparency = 0.574 closeBtn.Text = "✕"75 closeBtn.TextColor3 = Color3.fromRGB(255, 255, 255)76 closeBtn.TextSize = 1477 closeBtn.Font = Enum.Font.GothamBold78 closeBtn.BorderSizePixel = 079 closeBtn.Parent = titleBar8081 local statusLabel = Instance.new("TextLabel")82 statusLabel.Size = UDim2.new(1, -20, 0, 25)83 statusLabel.Position = UDim2.new(0, 10, 0, 45)84 statusLabel.BackgroundTransparency = 185 statusLabel.Text = "🔴 Disabled"86 statusLabel.TextColor3 = Color3.fromRGB(255, 100, 100)87 statusLabel.TextSize = 1488 statusLabel.Font = Enum.Font.Gotham89 statusLabel.TextXAlignment = Enum.TextXAlignment.Left90 statusLabel.Parent = mainFrame9192 local mouseStatusLabel = Instance.new("TextLabel")93 mouseStatusLabel.Size = UDim2.new(1, -20, 0, 22)94 mouseStatusLabel.Position = UDim2.new(0, 10, 0, 72)95 mouseStatusLabel.BackgroundTransparency = 196 mouseStatusLabel.Text = "🖱️ Mouse: Free"97 mouseStatusLabel.TextColor3 = Color3.fromRGB(180, 180, 200)98 mouseStatusLabel.TextSize = 1399 mouseStatusLabel.Font = Enum.Font.Gotham100 mouseStatusLabel.TextXAlignment = Enum.TextXAlignment.Left101 mouseStatusLabel.Parent = mainFrame102103 local mouseHintLabel = Instance.new("TextLabel")104 mouseHintLabel.Size = UDim2.new(1, -20, 0, 18)105 mouseHintLabel.Position = UDim2.new(0, 10, 0, 94)106 mouseHintLabel.BackgroundTransparency = 1107 mouseHintLabel.Text = "Ctrl + LMB — toggle mouse"108 mouseHintLabel.TextColor3 = Color3.fromRGB(130, 130, 150)109 mouseHintLabel.TextSize = 11110 mouseHintLabel.Font = Enum.Font.Gotham111 mouseHintLabel.TextXAlignment = Enum.TextXAlignment.Left112 mouseHintLabel.Parent = mainFrame113114 local toggleBtn = Instance.new("TextButton")115 toggleBtn.Size = UDim2.new(0, 80, 0, 35)116 toggleBtn.Position = UDim2.new(1, -90, 0, 100)117 toggleBtn.BackgroundColor3 = Color3.fromRGB(200, 60, 60)118 toggleBtn.BackgroundTransparency = 0.2119 toggleBtn.Text = "START"120 toggleBtn.TextColor3 = Color3.fromRGB(255, 255, 255)121 toggleBtn.TextSize = 14122 toggleBtn.Font = Enum.Font.GothamBold123 toggleBtn.BorderSizePixel = 0124 toggleBtn.Parent = mainFrame125126 local dragging = false127 local dragStart, startPos128129 titleBar.InputBegan:Connect(function(input)130 if input.UserInputType == Enum.UserInputType.MouseButton1 and not isCtrlDown() then131 dragging = true132 dragStart = input.Position133 startPos = mainFrame.Position134 end135 end)136137 titleBar.InputEnded:Connect(function(input)138 if input.UserInputType == Enum.UserInputType.MouseButton1 then139 dragging = false140 end141 end)142143 UserInputService.InputChanged:Connect(function(input)144 if dragging and input.UserInputType == Enum.UserInputType.MouseMovement then145 local delta = input.Position - dragStart146 mainFrame.Position = UDim2.new(147 startPos.X.Scale, startPos.X.Offset + delta.X,148 startPos.Y.Scale, startPos.Y.Offset + delta.Y149 )150 end151 end)152153 closeBtn.MouseButton1Click:Connect(function()154 Settings.Enabled = false155 setMouseLocked(false)156 screenGui:Destroy()157 end)158159 return screenGui, toggleBtn, statusLabel, mouseStatusLabel, mouseHintLabel160end161162local gui, toggleBtn, statusLabel, mouseStatusLabel, mouseHintLabel = CreateUI()163local isRunning = false164local currentCoroutine = nil165166local function updateMouseUI(ctrlActive)167 if Settings.MouseLocked then168 mouseStatusLabel.Text = "🖱️ Mouse: Locked"169 mouseStatusLabel.TextColor3 = Color3.fromRGB(100, 200, 255)170 else171 mouseStatusLabel.Text = "🖱️ Mouse: Free"172 mouseStatusLabel.TextColor3 = Color3.fromRGB(180, 180, 200)173 end174175 if ctrlActive then176 mouseHintLabel.Text = "Ctrl + LMB — toggle mouse (Ctrl held)"177 mouseHintLabel.TextColor3 = Color3.fromRGB(255, 220, 100)178 else179 mouseHintLabel.Text = "Ctrl + LMB — toggle mouse"180 mouseHintLabel.TextColor3 = Color3.fromRGB(130, 130, 150)181 end182end183184local function toggleMouse()185 setMouseLocked(not Settings.MouseLocked)186 updateMouseUI(isCtrlDown())187end188189UserInputService.InputBegan:Connect(function(input, gameProcessed)190 if input.UserInputType == Enum.UserInputType.MouseButton1 and isCtrlDown() then191 toggleMouse()192 return193 end194195 if input.KeyCode == Enum.KeyCode.LeftControl or input.KeyCode == Enum.KeyCode.RightControl then196 updateMouseUI(true)197 end198end)199200UserInputService.InputEnded:Connect(function(input)201 if input.KeyCode == Enum.KeyCode.LeftControl or input.KeyCode == Enum.KeyCode.RightControl then202 updateMouseUI(false)203 end204end)205206updateMouseUI(false)207208local Loader = require(ReplicatedStorage.Packages.Loader)209local ReplicaController = require(Loader.Shared.Utility.ReplicaController)210local BooksData = require(Loader.Shared.Data.Books)211212local LibraryReplica = nil213for _, r in pairs(ReplicaController._replicas) do214 if r.Class == "Library" then215 LibraryReplica = r216 break217 end218end219220if not LibraryReplica then221 ReplicaController.ReplicaOfClassCreated("Library", function(replica)222 LibraryReplica = replica223 end)224 while not LibraryReplica do225 task.wait()226 end227end228229local Library = Workspace.Library230local BooksFolder = Library.Books231local player = Players.LocalPlayer232233player.CameraMode = Enum.CameraMode.Classic234player.CameraMinZoomDistance = 20235task.spawn(function()236 task.wait(0.1)237 player.CameraMinZoomDistance = 0.5238end)239240local shelfModels = {}241for _, shelfModel in ipairs(CollectionService:GetTagged("Shelf")) do242 shelfModels[shelfModel.Name] = shelfModel243end244245local function getShelfAssignedSeries(shelfId)246 local shelfData = LibraryReplica.Data.Shelves[shelfId]247 if not shelfData then return nil end248 for _, placedBook in pairs(shelfData.Books) do249 local bookName = typeof(placedBook) == "Instance" and placedBook.Name or placedBook250 local seriesName = bookName:match("^(.-)_(.+)$")251 if seriesName then return seriesName end252 end253end254255local function findShelfForSeries(seriesName, genreName, volumeCount)256 for shelfId, shelfData in pairs(LibraryReplica.Data.Shelves) do257 if not shelfData.Completed and shelfData.Category == genreName then258 local shelfModel = shelfModels[shelfId]259 if shelfModel and shelfModel:GetAttribute("Width") == volumeCount then260 if getShelfAssignedSeries(shelfId) == seriesName then261 return shelfModel262 end263 end264 end265 end266267 for shelfId, shelfData in pairs(LibraryReplica.Data.Shelves) do268 if not shelfData.Completed and shelfData.Category == genreName then269 local shelfModel = shelfModels[shelfId]270 if shelfModel and shelfModel:GetAttribute("Width") == volumeCount then271 if not getShelfAssignedSeries(shelfId) and next(shelfData.Books) == nil then272 return shelfModel273 end274 end275 end276 end277end278279local function teleportTo(obj)280 local char = player.Character281 local root = char and char:FindFirstChild("HumanoidRootPart")282 local part = obj:IsA("Model") and (obj.PrimaryPart or obj:FindFirstChildOfClass("BasePart")) or obj283 if root and part then284 root.CFrame = CFrame.new(part.Position + Vector3.new(0, 2, 0))285 task.wait(0.05)286 end287end288289local function organizeBooks()290 for _, book in ipairs(BooksFolder:GetChildren()) do291 if not isRunning then break end292 task.wait(0.02)293294 local seriesName, volumeStr = book.Name:match("^(.-)_(.+)$")295 local volumeNum = tonumber(volumeStr)296 if seriesName and volumeNum then297 local genreName, bookInfo = BooksData.GetCategory(seriesName)298 if genreName and bookInfo then299 local shelfModel = findShelfForSeries(seriesName, genreName, bookInfo.VolumeCount)300 if shelfModel then301 local shelfData = LibraryReplica.Data.Shelves[shelfModel.Name]302 if not (shelfData and shelfData.Books[tostring(volumeNum)]) then303 teleportTo(book)304 LibraryReplica:FireServer("Grab", book)305 task.wait(0.1)306 teleportTo(shelfModel)307 LibraryReplica:FireServer("Place", shelfModel, volumeNum - 1)308 task.wait(0.4)309 end310 end311 end312 end313 end314end315316local function toggleScript()317 isRunning = not isRunning318319 if isRunning then320 toggleBtn.Text = "STOP"321 toggleBtn.BackgroundColor3 = Color3.fromRGB(60, 200, 60)322 statusLabel.Text = "🟢 Running..."323 statusLabel.TextColor3 = Color3.fromRGB(100, 255, 100)324 Settings.Enabled = true325326 safeCancel(currentCoroutine)327 currentCoroutine = task.spawn(function()328 while isRunning do329 local success, err = pcall(organizeBooks)330 if not success then331 warn("Book Organizer error:", err)332 statusLabel.Text = "❌ Error"333 statusLabel.TextColor3 = Color3.fromRGB(255, 100, 100)334 task.wait(2)335 end336 task.wait(5)337 end338 end)339 else340 toggleBtn.Text = "START"341 toggleBtn.BackgroundColor3 = Color3.fromRGB(200, 60, 60)342 statusLabel.Text = "🔴 Disabled"343 statusLabel.TextColor3 = Color3.fromRGB(255, 100, 100)344 Settings.Enabled = false345346 safeCancel(currentCoroutine)347 currentCoroutine = nil348 end349end350351toggleBtn.MouseButton1Click:Connect(toggleScript)352353Players.LocalPlayer:WaitForChild("PlayerGui").ChildRemoved:Connect(function(child)354 if child.Name == "BookOrganizerGUI" then355 isRunning = false356 setMouseLocked(false)357 safeCancel(currentCoroutine)358 currentCoroutine = nil359 end360end)361362print("✅ Book Organizer loaded! Ctrl+LMB toggles mouse. Click START to begin.")Change Log
1 entries- Publishedbebra
Script published
More Clean The Library 📖 scripts
Open place hubNo related scripts yet
Other scripts for this place will appear here when they are published.
Comments
…