Part Editor Plugin Affects Only Selected

I’m fixing my plugin again, and I’ve found a new problem. The settings UI works correctly, but even with different settings enabled on my plugin, they still affect only the selected parts, and not their children or descendants. If you’re wondering, the settings are Affect Selected Only, Affect Children and Affect Descendants. Here’s my current script (I found no errors, probably just my mind)

print("Plugin Status: Running")
	--Services
local selection = game:GetService("Selection") --selection
local IS = game:GetService("InsertService")
--local Model = IS:LoadAsset(ID)
local CHS = game:GetService("ChangeHistoryService")
print("Services Variables Loaded")

	--GUI Variables
local gui = script:WaitForChild("PartEditor") --Gui
local open = false --Is not opened
local descendantsOnly = gui.Settings:FindFirstChild("Descendants")
local childrenOnly = descendantsOnly.Parent:FindFirstChild("Children")
local parentOnly = childrenOnly.Parent:FindFirstChild("Parent")
local chosen

local transparencybutton = gui:WaitForChild("TransparencySetter"):WaitForChild("SetTransparency") --transparency setter
local transparencytextbox = transparencybutton.Parent.ValueBox

local anchorbutton = gui:WaitForChild("AnchorSetter"):WaitForChild("SetAnchor") --anchor setter
local anchortextbox = anchorbutton.Parent.ValueBox

local collisionbutton = gui:WaitForChild("CollisionSetter"):WaitForChild("SetCollision") --collision setter
local collisiontextbox = collisionbutton.Parent.ValueBox

print("GUI Variables Loaded")

	--Functions
function parentsOnly(selection)
	return selection
end

function 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 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 check(descendantsa, children, parent, selected)
	if descendantsa then
		return descendants(selected)
	elseif children then
		return children(selected)
	else
		return parent(selected)
	end
end

function doWhatever(chosenProperty)
	local get = selection:Get()
	local check = check(descendantsOnly, childrenOnly, parentOnly, get)
	local num = tonumber(transparencytextbox.Text)
	local bool = anchortextbox.Text
	if chosenProperty == "Transparency" then
		if num then -- checking to see if the text was converted successfully
			if num >= 0 and num <= 1 then -- flipped the signs
				for i, part in pairs(get) do
					if part:IsA("BasePart") then
						if parentOnly then
							if part:IsA("BasePart") then
								part.Transparency = num
							end
						elseif descendantsOnly or childrenOnly then
							for i, descendante in pairs(check) do
								if descendante:IsA("BasePart") then
								descendante.Transparency = num
								end
							end
						end
					end
				end
			else
				print("There was an error, try again.")
			end
		end
	elseif chosenProperty == "Anchored" then
		if bool then
			if bool == "true" then
				if parentOnly then
					for i, part in pairs(get) do
						if part:IsA("BasePart") then
							part.Anchored = true
						end
					end
				elseif descendantsOnly or childrenOnly then
					for i, part in pairs(check) do
						if part:IsA("BasePart") then
							part.Anchored = true
						end
					end
				end	
			elseif bool == "false" then
				if parentOnly then
					for i, part in pairs(get) do
						if part:IsA("BasePart") then
							part.Anchored = false
						end
					end
				elseif descendantsOnly or childrenOnly then
					for i, part in pairs(check) do
						if part:IsA("BasePart") then
							part.Anchored = false
						end
					end
				end
			end
		else
			print("There was an error, try again.")
		end	
	end
end
	--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 open == false then
		gui.Parent = game:GetService("CoreGui")
		open = true
		gui.Core.Visible = true
	else
		gui.Parent = script
		open = false
		gui.Core.Visible = false
	end
end)

	--Connected Events
transparencybutton.MouseButton1Click:Connect(function() --tried moving this event to a local script, didn't work
	chosen = "Transparency"
	doWhatever(chosen)
end)
anchorbutton.MouseButton1Click:Connect(function() --tried moving this event to a local script, didn't work
	chosen = "Anchored"
	doWhatever(chosen)
end)
collisionbutton.MouseButton1Click:Connect(function() --tried moving this event to a local script, didn't work
	print("Button pressed, Server")
	chosen = "Collision"
	local get = selection:Get()
	local bool = 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)

(Parent Only setting is Selected Only.) Thanks!

Like I said you should use :GetDescendants and not a child called descendants

Like I said on my other post it was referring to a bool value called descendants

Then how can a bool affect the descendants? I’m sorry but I don’t really understand. A bool only contains true or false, and not instances.

It’s part of settings, false means off, true means on.

Oh I see. Did printing show you anything? Were there any errors?

No errors, I’ve been checking for the past 10 minutes

Can this be fixed? I have been looking at the script for a LONG time without finding anything.

It’s been 13 hours and nobody replied… I’ll try to fix this later after school.
For those who tell me to do any of these: renaming the parameters in the check function didn’t work, the descendants bool value was set to true in the settings during testing, and I’ve tried renaming the variables used in the doWhatever function