Remove Part Universal KEYLESS
Key RequiredUniversal

Remove Part Universal KEYLESS

Universal Scriptbettusanbettusan 2K views 164 executesUpdated Oct 13, 2025
Unrated
00
Lua Script•86 lines (2575 chars)
-- f1 - remove
-- f2 - undo
-- f4 - undo all

-- LocalScript in StarterPlayerScripts
local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local mouse = player:GetMouse()

-- table of removed objects
local removedStack = {}

-- check: is the object part of a character (does the model have a Humanoid)?
local function isCharacterPart(part)
    if part and part.Parent then
        if part.Parent:FindFirstChildOfClass("Humanoid") then
            return true
        end
    end
    return false
end

-- delete the object under the cursor
local function deletePartUnderCursor()
    local target = mouse.Target
    if target and (target:IsA("Part") or target:IsA("MeshPart") or target:IsA("UnionOperation")) then
        if isCharacterPart(target) then
            warn("You cannot delete character parts!")
            return
        end

        -- save the object and its parent in the stack
        table.insert(removedStack, {
            object = target,
            parent = target.Parent
        })

        target.Parent = nil -- hide the object
        print("Deleted object:", target.Name, "(in stack:", #removedStack .. ")")
    else
        print("No suitable object under the cursor")
    end
end

-- restore the last removed object
local function restoreLastPart()
    if #removedStack > 0 then
        local data = table.remove(removedStack) -- get the last one
        if data.object and data.parent then
            data.object.Parent = data.parent
            print("Restored object:", data.object.Name, "(remaining in stack:", #removedStack .. ")")
        end
    else
        warn("No removed objects to restore")
    end
end

-- restore all removed objects
local function restoreAllParts()
    if #removedStack > 0 then
        for i = #removedStack, 1, -1 do
            local data = removedStack[i]
            if data.object and data.parent then
                data.object.Parent = data.parent
            end
            table.remove(removedStack, i)
        end
        print("All objects restored")
    else
        warn("No removed objects to restore")
    end
end

-- key input handling
UserInputService.InputBegan:Connect(function(input, gameProcessed)
    if not gameProcessed then
        if input.KeyCode == Enum.KeyCode.F1 then
            deletePartUnderCursor()
        elseif input.KeyCode == Enum.KeyCode.F2 then
            restoreLastPart()
        elseif input.KeyCode == Enum.KeyCode.F4 then
            restoreAllParts()
        end
    end
end)

Features & Information

Binds f1 - remove f2 - undo f4 - undo all

Community Comments (2)

RCDHookifyRCDHookifyOct 13, 2025

Can other people see?

Replying to @RCDHookify
bettusanbettusanOct 14, 2025

@RCDHookify No, this is only for the client.

More Scripts for Universal Scripts