Toggle BasePart.Locked - Plugin

Hi, I’m @RuizuKun_Dev,

I made a plugin that Sets ALL BasePart.Locked to either true or false depending on the button you press and will also set for newly added BaseParts to workspace.

Why would anyone need this?

From my experience as a Game Developer, you do not want to accidentally drag your entire workspace or a big model and working in TeamCreate with a Builder can require Parts to be Locked and Unlocked
so to make that easy for the both of us I have created this plugin and decided to share it with whom ever may need be.


Resources

https://www.roblox.com/library/4581199986/Toggle-BasePart-Locked

Source Code
local toolbar = plugin:CreateToolbar("Toggle BasePart.Locked")
 

local UnlockBtn = toolbar:CreateButton("Unlock ALL BaseParts", "BasePart.Locked = false", "rbxassetid://4581192102")
local LockBtn = toolbar:CreateButton("Lock ALL BaseParts", "BasePart.Locked = true", "rbxassetid://4581192286")

local LockNewBaseParts;
 
UnlockBtn.Click:Connect(function()
	LockBtn:SetActive(false)
	for _,v in ipairs(workspace:GetDescendants()) do
		if v:IsA("BasePart") then
			v.Locked = false
		end
	end
	LockNewBaseParts = false
	UnlockBtn:SetActive(true)
--	print("ALL BaseParts Are Unlocked")
end)

LockBtn.Click:Connect(function()
	UnlockBtn:SetActive(false)
	for _,v in ipairs(workspace:GetDescendants()) do
		if v:IsA("BasePart") then
			v.Locked = true
		end
	end
	LockNewBaseParts = true
	LockBtn:SetActive(true)
--	print("ALL BaseParts Are Locked")
end)

workspace.DescendantAdded:Connect(function(AddedDescendant)
	if AddedDescendant:IsA("BasePart") then
		AddedDescendant.Locked = LockNewBaseParts
	end
end)

Toggle BasePart.Locked - Plugin.lua (1.0 KB)



4 Likes

Very useful for developing games to prevent any bugs with the rigs!

Not to be a killjoy, but…

image

(the other half of the plugin is neat too, I suppose)

5 Likes

I’m gonna give myself a pat in the back and go with “99% of Users probably doesn’t know that it exist”, so my (hard work) is justified.

It’s also easier to navigate and I also had a little bit of fun while making the plugin so it was worth it.

3 Likes

Not saying it invalidates your plugin completely! The ability to lock new parts is pretty interesting, but might be better incorporated into a different plugin dedicated to that kind of stuff. We’ll see :slightly_smiling_face:

1 Like