MaxproGlitcher

Remove Part Universal KEYLESS .lua

Oct 13th, 2025
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.60 KB | None | 0 0
  1.  
  2. -- f1 - remove
  3. -- f2 - undo
  4. -- f4 - undo all
  5.  
  6. -- LocalScript in StarterPlayerScripts
  7. local UserInputService = game:GetService("UserInputService")
  8. local Players = game:GetService("Players")
  9. local player = Players.LocalPlayer
  10. local mouse = player:GetMouse()
  11.  
  12. -- table of removed objects
  13. local removedStack = {}
  14.  
  15. -- check: is the object part of a character (does the model have a Humanoid)?
  16. local function isCharacterPart(part)
  17. if part and part.Parent then
  18. if part.Parent:FindFirstChildOfClass("Humanoid") then
  19. return true
  20. end
  21. end
  22. return false
  23. end
  24.  
  25. -- delete the object under the cursor
  26. local function deletePartUnderCursor()
  27. local target = mouse.Target
  28. if target and (target:IsA("Part") or target:IsA("MeshPart") or target:IsA("UnionOperation")) then
  29. if isCharacterPart(target) then
  30. warn("You cannot delete character parts!")
  31. return
  32. end
  33.  
  34. -- save the object and its parent in the stack
  35. table.insert(removedStack, {
  36. object = target,
  37. parent = target.Parent
  38. })
  39.  
  40. target.Parent = nil -- hide the object
  41. print("Deleted object:", target.Name, "(in stack:", #removedStack .. ")")
  42. else
  43. print("No suitable object under the cursor")
  44. end
  45. end
  46.  
  47. -- restore the last removed object
  48. local function restoreLastPart()
  49. if #removedStack > 0 then
  50. local data = table.remove(removedStack) -- get the last one
  51. if data.object and data.parent then
  52. data.object.Parent = data.parent
  53. print("Restored object:", data.object.Name, "(remaining in stack:", #removedStack .. ")")
  54. end
  55. else
  56. warn("No removed objects to restore")
  57. end
  58. end
  59.  
  60. -- restore all removed objects
  61. local function restoreAllParts()
  62. if #removedStack > 0 then
  63. for i = #removedStack, 1, -1 do
  64. local data = removedStack[i]
  65. if data.object and data.parent then
  66. data.object.Parent = data.parent
  67. end
  68. table.remove(removedStack, i)
  69. end
  70. print("All objects restored")
  71. else
  72. warn("No removed objects to restore")
  73. end
  74. end
  75.  
  76. -- key input handling
  77. UserInputService.InputBegan:Connect(function(input, gameProcessed)
  78. if not gameProcessed then
  79. if input.KeyCode == Enum.KeyCode.F1 then
  80. deletePartUnderCursor()
  81. elseif input.KeyCode == Enum.KeyCode.F2 then
  82. restoreLastPart()
  83. elseif input.KeyCode == Enum.KeyCode.F4 then
  84. restoreAllParts()
  85. end
  86. end
  87. end)
  88.  
Advertisement
Add Comment
Please, Sign In to add comment