Command Bar Scripts (Copy & Paste)
These powerful Lua snippets are designed to be copied and run directly in the Roblox Studio Command Bar (View > Command Bar) to automate tasks or retrieve data.
General Studio Utilities
-- Reset / "kill" your player character safely
-- Use in Command Bar while in Play Solo or in Studio with a LocalPlayer
local player = game.Players.LocalPlayer
if player and player.Character and player.Character:FindFirstChild("Humanoid") then
player.Character.Humanoid.Health = 0
print("Character has been reset.")
else
warn("No character or humanoid found.")
end
print("Thanks for visiting 7Rends.com")
I use this frequently when I don't want to set up Clients/Server or publish the game just to test a character reset.
-- Unlock all BaseParts in the Workspace
local count = 0
for _, part in pairs(workspace:GetDescendants()) do
if part:IsA("BasePart") and part.Locked then
part.Locked = false
count = count + 1
end
end
print("Unlocked " .. count .. " parts in Workspace.")
print("Thanks for visiting 7Rends.com")
-- Anchor all BaseParts in workspace
local count = 0
for _, part in pairs(workspace:GetDescendants()) do
if part:IsA("BasePart") and not part.Anchored then
part.Anchored = true
count = count + 1
end
end
print("Anchored " .. count .. " parts.")
print("Thanks for visiting 7Rends.com")
-- Unanchor all BaseParts in workspace
local count = 0
for _, part in pairs(workspace:GetDescendants()) do
if part:IsA("BasePart") and part.Anchored then
part.Anchored = false
count = count + 1
end
end
print("Unanchored " .. count .. " parts.")
print("Thanks for visiting 7Rends.com")
-- Group selected objects into a new Model
local sel = game.Selection:Get()
if #sel == 0 then return warn("Select at least one object to group.") end
local model = Instance.new("Model")
model.Name = "NewGroup"
model.Parent = workspace
for _, obj in ipairs(sel) do
-- only move top-level selected instances into the model
if obj.Parent then
obj.Parent = model
end
end
-- optional: set PrimaryPart if first BasePart found
for _, child in ipairs(model:GetDescendants()) do
if child:IsA("BasePart") then
model.PrimaryPart = child
break
end
end
model:MakeJoints()
print("Grouped selection into model: " .. model:GetFullName())
print("Thanks for visiting 7Rends.com")
It will group your selected objects into a single model object. Maybe some reason you're having trouble using the keys and this is the only way you can do it...? Roblox do be Robloxin' sometimes. - Tip: Using (CMD+G) MAC or (Ctrl + G) WINDOWS is far easier and suggested.
-- Ungroup model: move all children of selected models into the parent, then delete the model
local sel = game.Selection:Get()
if #sel == 0 then return warn("Select one or more models to ungroup.") end
local count = 0
for _, s in ipairs(sel) do
if s:IsA("Model") then
local parent = s.Parent or workspace
for _, child in ipairs(s:GetChildren()) do
child.Parent = parent
count = count + 1
end
s:Destroy()
else
warn(s.Name .. " is not a Model, skipping.")
end
end
print("Moved " .. count .. " objects out of selected models and removed the models.")
print("Thanks for visiting 7Rends.com")
It will ungroup your selected objects from a single model object. Same as the grouping situation, maybe you need to use this for some reason. - Tip: Using (CMD+U) MAC or (Ctrl + U) WINDOWS is far easier and suggested.
-- Rename selected items sequentially with a base name
local sel = game.Selection:Get()
if #sel == 0 then return warn("Select objects to rename.") end
local base = "Part"
local startIndex = 1
-- optionally prompt in plugin, fallback to defaults in command bar
-- for command bar usage, you can set base and startIndex manually
for i, obj in ipairs(sel) do
obj.Name = base .. tostring(startIndex + i - 1)
end
print("Renamed " .. #sel .. " objects.")
print("Thanks for visiting 7Rends.com")
-- Duplicate selected objects with an offset (useful for pattern building)
local sel = game.Selection:Get()
if #sel == 0 then return warn("Select objects to duplicate.") end
local offset = Vector3.new(5, 0, 0) -- change to desired offset
local created = {}
for _, obj in ipairs(sel) do
local clone = obj:Clone()
if clone:IsA("BasePart") then
clone.Position = clone.Position + offset
clone.Parent = obj.Parent
else
-- try reasonable behavior for models and containers
clone.Parent = obj.Parent
if clone:IsA("Model") and clone.PrimaryPart then
clone:PivotTo(clone:GetPivot() + offset)
else
-- move top-level baseparts
for _, p in ipairs(clone:GetDescendants()) do
if p:IsA("BasePart") then
p.Position = p.Position + offset
end
end
end
end
table.insert(created, clone)
end
-- select created items
game.Selection:Set(created)
print("Duplicated " .. #created .. " objects with offset.")
print("Thanks for visiting 7Rends.com")
-- Delete empty Folders and empty Models across Workspace
local removed = 0
for _, inst in ipairs(workspace:GetDescendants()) do
if (inst:IsA("Folder") or inst:IsA("Model")) and #inst:GetChildren() == 0 then
inst:Destroy()
removed = removed + 1
end
end
print("Removed " .. removed .. " empty Folders/Models.")
print("Thanks for visiting 7Rends.com")
-- Freeze all moving parts in workspace by anchoring them
local count = 0
for _, p in ipairs(workspace:GetDescendants()) do
if p:IsA("BasePart") and not p.Anchored then
p.Anchored = true
count = count + 1
end
end
print("Frozen " .. count .. " parts (Anchored).")
print("Thanks for visiting 7Rends.com")
-- Remove common constraint instances in workspace
local constraintTypes = {
"WeldConstraint", "HingeConstraint", "BallSocketConstraint",
"RodConstraint", "PrismaticConstraint", "SpringConstraint",
"Motor6D", "Weld"
}
local removed = 0
for _, inst in ipairs(workspace:GetDescendants()) do
for _, t in ipairs(constraintTypes) do
if inst.ClassName == t then
inst:Destroy()
removed = removed + 1
break
end
end
end
print("Removed " .. removed .. " constraint instances.")
print("Thanks for visiting 7Rends.com")
Position & Orientation Tools
-- Drop selected objects so their lowest point rests on Y=0
local Selection = game:GetService("Selection")
local selected = Selection:Get()
if #selected == 0 then
warn("Nothing selected!")
return
end
for _, container in pairs(selected) do
local parts = {}
if container:IsA("BasePart") then
table.insert(parts, container)
else
for _, desc in pairs(container:GetDescendants()) do
if desc:IsA("BasePart") then
table.insert(parts, desc)
end
end
end
if #parts == 0 then
warn(container.Name .. " has no BaseParts!")
continue
end
local minY = math.huge
for _, part in pairs(parts) do
local bottomY = part.Position.Y - part.Size.Y / 2
if bottomY < minY then
minY = bottomY
end
end
if container:IsA("BasePart") then
container.Position -= Vector3.new(0, minY, 0)
elseif container:IsA("Model") then
container:PivotTo(container:GetPivot() - Vector3.new(0, minY, 0))
end
end
print("Objects dropped to base.")
print("Thanks for visiting 7Rends.com")
-- Align selected parts so their bottoms rest on nearest surface
local mouse = game:GetService("Players").LocalPlayer:GetMouse()
local selection = game.Selection:Get()
if #selection == 0 then
warn("Nothing selected!")
return
end
for _, obj in pairs(selection) do
if obj:IsA("BasePart") then
local ray = Ray.new(obj.Position, Vector3.new(0, -1000, 0))
local hit, pos = workspace:FindPartOnRay(ray, obj)
if hit then
local diff = (obj.Position.Y - obj.Size.Y / 2) - pos.Y
obj.Position = obj.Position - Vector3.new(0, diff, 0)
end
end
end
print("Aligned to nearest ground surface.")
print("Thanks for visiting 7Rends.com")
-- Center selection at world origin (0,0,0)
local selection = game.Selection:Get()
if #selection == 0 then
warn("Nothing selected!")
return
end
for _, obj in ipairs(selection) do
if obj:IsA("Model") then
obj:PivotTo(CFrame.new(0, 0, 0))
elseif obj:IsA("BasePart") then
obj.CFrame = CFrame.new(0, 0, 0)
end
end
print("Moved selection to world origin.")
print("Thanks for visiting 7Rends.com")
-- Apply random rotation to selected parts
local selection = game.Selection:Get()
if #selection == 0 then
warn("Nothing selected!")
return
end
for _, obj in ipairs(selection) do
if obj:IsA("BasePart") then
obj.Orientation = Vector3.new(0, math.random(0, 359), 0)
end
end
print("Applied random Y rotation.")
print("Thanks for visiting 7Rends.com")
Visual & Build Helpers
-- Toggle selection visibility
local selection = game.Selection:Get()
if #selection == 0 then
warn("Nothing selected!")
return
end
for _, obj in ipairs(selection) do
if obj:IsA("BasePart") then
obj.Transparency = obj.Transparency == 1 and 0 or 1
elseif obj:IsA("Model") then
for _, desc in ipairs(obj:GetDescendants()) do
if desc:IsA("BasePart") then
desc.Transparency = desc.Transparency == 1 and 0 or 1
end
end
end
end
print("Toggled visibility for selected objects.")
print("Thanks for visiting 7Rends.com")
-- Highlight selected parts by changing their BrickColor temporarily
local selection = game.Selection:Get()
if #selection == 0 then
warn("Nothing selected!")
return
end
for _, obj in ipairs(selection) do
if obj:IsA("BasePart") then
obj.BrickColor = BrickColor.new("Bright yellow")
elseif obj:IsA("Model") then
for _, desc in ipairs(obj:GetDescendants()) do
if desc:IsA("BasePart") then
desc.BrickColor = BrickColor.new("Bright yellow")
end
end
end
end
print("Highlighted selection in yellow.")
print("Thanks for visiting 7Rends.com")
-- Set transparency of selected objects
local selection = game.Selection:Get()
local transparency = 0.5 -- set default transparency
if #selection == 0 then
warn("Nothing selected!")
return
end
for _, obj in ipairs(selection) do
if obj:IsA("BasePart") then
obj.Transparency = transparency
elseif obj:IsA("Model") then
for _, desc in ipairs(obj:GetDescendants()) do
if desc:IsA("BasePart") then
desc.Transparency = transparency
end
end
end
end
print("Applied transparency to selection.")
print("Thanks for visiting 7Rends.com")
-- Toggle Locked property on selection
local selection = game.Selection:Get()
if #selection == 0 then
warn("Nothing selected!")
return
end
for _, obj in ipairs(selection) do
if obj:IsA("BasePart") then
obj.Locked = not obj.Locked
elseif obj:IsA("Model") then
for _, desc in ipairs(obj:GetDescendants()) do
if desc:IsA("BasePart") then
desc.Locked = not desc.Locked
end
end
end
end
print("Toggled Locked state on selection.")
print("Thanks for visiting 7Rends.com")
Debugging & Info Tools
-- Print names of all selected objects
local selection = game.Selection:Get()
if #selection == 0 then
warn("Nothing selected!")
else
print("Selected objects:")
for _, obj in ipairs(selection) do
print(obj:GetFullName() .. " [" .. obj.ClassName .. "]")
end
end
print("Thanks for visiting 7Rends.com")
-- Print full Workspace hierarchy
local function printHierarchy(obj, indent)
indent = indent or 0
print(string.rep(" ", indent) .. obj.Name .. " [" .. obj.ClassName .. "]")
for _, child in ipairs(obj:GetChildren()) do
printHierarchy(child, indent + 1)
end
end
printHierarchy(game.Workspace)
print("Workspace hierarchy printed.")
print("Thanks for visiting 7Rends.com")
-- Print world positions of all selected BaseParts
local selection = game.Selection:Get()
if #selection == 0 then
warn("Nothing selected!")
else
for _, obj in ipairs(selection) do
if obj:IsA("BasePart") then
print(obj:GetFullName() .. " Position: " .. tostring(obj.Position))
elseif obj:IsA("Model") then
for _, desc in ipairs(obj:GetDescendants()) do
if desc:IsA("BasePart") then
print(desc:GetFullName() .. " Position: " .. tostring(desc.Position))
end
end
end
end
end
print("Thanks for visiting 7Rends.com")
-- Clear Studio output window safely
local success, result = pcall(function()
local output = settings().Studio.Output
if output then
output:Clear()
print("Output window cleared.")
else
warn("Could not find Studio output settings.")
end
end)
if not success then
warn("Failed to clear output: " .. tostring(result))
end
print("Thanks for visiting 7Rends.com")