PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
Collapse Sidebar

Locked

BasePart

bool

The Locked property determines whether a BasePart|part (or a Model|model it is contained within) may be selected in Roblox Studio by clicking on it. This property is most often enabled on parts within environment models that aren’t being edited at the moment. Roblox Studio has a Lock/Unlock All tool that can toggle the Locked state of every part descendant in a model at once.


Code Samples


Recursive Unlock

This code sample uses the concept of recursion to unlock all parts that are a descendant of a model.

-- Paste into a Script within a Model you want to unlock
local model = script.Parent

-- This function recurses through a model's heirarchy and unlocks
-- every part that it encounters. 
local function recursiveUnlock(object)
	if object:IsA("BasePart") then
		object.Locked = false
	end
	
	-- Call the same function on the children of the object
	-- Note: The recursive process stops if an object has no children
	for _, child in pairs(object:GetChildren()) do
		recursiveUnlock(child)
	end
end

recursiveUnlock(model)
-- You could unlock every part in the workspace by calling
-- the function with the workspace, like this:
--recursiveUnlock(workspace)