Transparency Setter Help

I’m making a part editor plugin, and I’m making a transparency setter. However, the script is broken, and it doesn’t show any errors. I fixed up my script again but still the same issue. My local script:

local button = script.Parent
local textbox = button.Parent.ValueBox
local selection = game:GetService("Selection")
button.MouseButton1Click:Connect(function()
	local table = selection:Get()
	local num
	local text = textbox.Text
	local success, str = pcall(function()
		num = tonumber(text)
	end)
	if success then
		if num <= 0 and num >= 1 then
			for i, v in pairs(table) do
				local part = table[i]
				if part.ClassName == "BasePart" or part.ClassName == "UnionOperation" then
					part.Transparency = num
				end
			end
		end
	else
		print("There was an error, try again.")
	end
end)

Thanks :slight_smile:
This isn’t fixed yet so I’d be glad if you’d help me.

As it is a plugin, I think that the script you put inside (except for the script that executes everything and the modules) can’t work, try placing the code inside the script that executes everything and this is slightly better

local button = script.Parent
local textbox = button.Parent.ValueBox
local Selection = game:GetService("Selection")

button.MouseButton1Click:Connect(function()
	local Get = Selection:Get()
	
	local success, num = pcall(tonumber, textbox.Text)
	if success and num <= 0 and num >= 1 then
		for _, part in pairs(Get) do
			if not part:IsA("BasePart") then		continue		end
			part.Transparency = num
		end
	else
		print("There was an error, try again.")
	end
end)

I tried moving the code to the main script, but it still didn’t work. I made sure I saved the plugin as well. Also, the local scripts that take the MouseButton1Click events work.

Hmm… if you put one print on top of the code and another inside the function, which one prints?

Both of them print.

Sorry I’m late I went on a lunch break

Can anyone help please? Nothing is working.

I changed the variable table to get and the print statement in my if success then statement is not working, my code:

local gui = script:WaitForChild("PartEditor") --Gui
local open = false --Is not opened
local button = gui:WaitForChild("TransparencySetter"):WaitForChild("SetTransparency") --transparency setter
local textbox = button.Parent.ValueBox --transparency value box
local selection = game:GetService("Selection") --selection
local IS = game:GetService("InsertService")
--local Model = IS:LoadAsset(ID)
local CHS = game:GetService("ChangeHistoryService")
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()
	print("Plugin Initialized")
	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)
--Button pressed
button.MouseButton1Click:Connect(function()
	print("Button pressed")
	local get = selection:Get()
	local num
	local text = textbox.Text
	local success, str = pcall(function()
		num = tonumber(text)
	end)
	if success then
		if num <= 0 and num >= 1 then
			for i, v in pairs(get) do
				local part = get[i]
				if part.ClassName == "BasePart" or part.ClassName == "UnionOperation" then
					part.Transparency = num
				end
			end
		end
	else
		print("There was an error, try again.")
	end
end)

Thanks for helping