I’m making this post because yesterday I had to make reposts since nobody FREAKING replied, so they were locked.
2 days ago I was experiencing a problem while creating my plugin. I added 3 settings, Affect Selected Only
, Affect Children
, and Affect Descendants
. I turned on affect descendants for testing, but it acted like affect selected only was still on. There were no errors in the output.
There are 3 scripts: The main script, the function manager, and the variable manager.
The variable manager:
local varManager = {}
varManager.selection = game:GetService("Selection") --selection
varManager.IS = game:GetService("InsertService")
--local Model = IS:LoadAsset(ID)
varManager.CHS = game:GetService("ChangeHistoryService")
varManager.gui = script.Parent:WaitForChild("PartEditor") --Gui
varManager.open = false --Is not opened
varManager.descendantsOnly = varManager.gui.Settings:FindFirstChild("Descendants")
varManager.childrenOnly = varManager.descendantsOnly.Parent:FindFirstChild("Children")
varManager.parentOnly = varManager.childrenOnly.Parent:FindFirstChild("Parent")
varManager.chosen = ""
varManager.transparencybutton = varManager.gui:WaitForChild("TransparencySetter"):WaitForChild("SetTransparency") --transparency setter
varManager.transparencytextbox = varManager.transparencybutton.Parent.ValueBox
varManager.anchorbutton = varManager.gui:WaitForChild("AnchorSetter"):WaitForChild("SetAnchor") --anchor setter
varManager.anchortextbox = varManager.anchorbutton.Parent.ValueBox
varManager.collisionbutton = varManager.gui:WaitForChild("CollisionSetter"):WaitForChild("SetCollision") --collision setter
varManager.collisiontextbox = varManager.collisionbutton.Parent.ValueBox
return varManager
The function manager:
local functionManager = {}
functionManager.varManager = require(script.Parent.VariableManager)
function functionManager.parentsOnly(selection)
return selection
end
function functionManager.descendants(selection)
local contents = {}
for i, v in pairs(selection) do
local descendants = v:GetDescendants()
for i, e in pairs(descendants) do
table.insert(contents, e)
end
end
return contents
end
function functionManager.children(selection)
local contents = {}
for i, v in pairs(selection) do
local children = v:GetChildren()
for i, e in pairs(children) do
table.insert(contents, e)
end
end
return contents
end
function functionManager.check(descendantsa, childrena, parenta, selected)
if descendantsa then
return functionManager.descendants(selected)
elseif childrena then
return functionManager.children(selected)
else
return functionManager.parentsOnly(selected)
end
end
function functionManager.doWhatever(chosenProperty)
functionManager.get = functionManager.varManager.selection:Get()
functionManager.checker = functionManager.check(functionManager.varManager.descendantsOnly, functionManager.varManager.childrenOnly, functionManager.varManager.parentOnly, functionManager.get)
functionManager.transparency = tonumber(functionManager.varManager.transparencytextbox.Text)
functionManager.isAnchored = functionManager.varManager.anchortextbox.Text
if chosenProperty == "Transparency" then
if functionManager.transparency then -- checking to see if the text was converted successfully
if functionManager.transparency >= 0 and functionManager.transparency <= 1 then -- flipped the signs
for i, part in pairs(functionManager.get) do
if part:IsA("BasePart") then
if functionManager.varManager.parentOnly then
if part:IsA("BasePart") then
part.Transparency = functionManager.transparency
end
elseif functionManager.varManager.descendantsOnly or functionManager.varManager.childrenOnly then
for i, descendante in pairs(functionManager.checker) do
if descendante:IsA("BasePart") then
descendante.Transparency = functionManager.transparency
end
end
end
end
end
else
print("There was an error, try again.")
end
end
elseif chosenProperty == "Anchored" then
if functionManager.isAnchored then
if functionManager.isAnchored == "true" then
if functionManager.varManager.parentOnly then
for i, part in pairs(functionManager.get) do
if part:IsA("BasePart") then
part.Anchored = true
end
end
elseif functionManager.varManager.descendantsOnly or functionManager.varManager.childrenOnly then
for i, part in pairs(functionManager.checker) do
if part:IsA("BasePart") then
part.Anchored = true
end
end
end
elseif functionManager.isAnchored == "false" then
if functionManager.varManager.parentOnly then
for i, part in pairs(functionManager.get) do
if part:IsA("BasePart") then
part.Anchored = false
end
end
elseif functionManager.varManager.descendantsOnly or functionManager.varManager.childrenOnly then
for i, part in pairs(functionManager.checker) do
if part:IsA("BasePart") then
part.Anchored = false
end
end
end
end
else
print("There was an error, try again.")
end
end
end
return functionManager
And the main script (I didn’t finish the collision function yet )
print("Plugin Status: Running")
local variableManager = require(script.VariableManager)
local functionManager = require(script.FunctionManager)
--Plugin Creation
local toolbar = plugin:CreateToolbar("Part Editor")
local newScriptButton = toolbar:CreateButton("EditPartEasily", "A better way to edit parts!", "rbxassetid://157942894", "Part Editor")
newScriptButton.Click:Connect(function()
if variableManager.open == false then
variableManager.gui.Parent = game:GetService("CoreGui")
variableManager.open = true
variableManager.gui.Core.Visible = true
else
variableManager.gui.Parent = script
variableManager.open = false
variableManager.gui.Core.Visible = false
end
end)
--Connected Events
variableManager.transparencybutton.MouseButton1Click:Connect(function() --tried moving this event to a local script, didn't work
chosen = "Transparency"
functionManager.doWhatever(chosen)
end)
variableManager.anchorbutton.MouseButton1Click:Connect(function() --tried moving this event to a local script, didn't work
chosen = "Anchored"
functionManager.doWhatever(chosen)
end)
variableManager.collisionbutton.MouseButton1Click:Connect(function() --tried moving this event to a local script, didn't work
print("Button pressed, Server")
chosen = "Collision"
local get = variableManager.selection:Get()
local bool = variableManager.collisiontextbox.Text
if bool then
if bool == "true" then
for i, part in pairs(get) do
if part:IsA("BasePart") then
part.CanCollide = true
end
end
elseif bool == "false" then
for i, part in pairs(get) do
if part:IsA("BasePart") then
part.CanCollide = false
end
end
end
else
print("There was an error, try again.")
end
end)
I hope this won’t get locked again, I just need help
Thanks for helping