Doesn't work when doing this:

Code:

local gui = workspace.NumPad.SurfaceGui  
for i,v in pairs(gui:GetChildren()) do
	if v:IsA('TextButton')	then 
		if v.Name ~= 'Clear' or 'Enter' then
			print(v.Name)
		end
	end
end 

Instances:
Sidebar

In return it prints every single textbutton’s name, including “Clear” and “Enter”. Which I’m trying not to print. It has been a gigantic burden for me. As I’ve tried many different ways to get it working, but all have had the same output.

Change this with

if v.Name ~= 'Clear' and 'Enter' then

When you do OR, if any of them is true, it will get executed. With AND, both of them need to be true for it to get executed

Or rather do

if v.Name ~= 'Clear' and v.Name ~= 'Enter' then
1 Like

This seems to work, but it’s rather long. Either way, I’m going to mark you as the solution. What surprises me the most is that I did this exact thing earlier.

If you want slightly shorter, you can do

local gui = workspace.NumPad.SurfaceGui
local guiTable = gui:GetChildren()

for i = 1, #guiTable do

if gui:FindFirstChild(toString(i)) then
   print(gui:FindFirstChild(toString(i)).Name)
end

end

There is no magic one line way to achieve what you want, but no need to worry about it. Both your original script and this one are not at all heavy on performance

Note that the original script is a better way of doing, the latter one i wrote is kind of hacky