How to correctly check if a part has studs/inlets?

I’ve seen in another devforum post that to check if a part has specific properties, to use pcall to check if there are specific properties, the only problem is that I don’t know how to check if there are surface studs/inlets. This is my current script, a server script in workspace.

for i, studpart in pairs(game.Workspace:GetDescendants()) do
	if studpart:IsA("Part") then
		local studcall = pcall(function() has (v, "Studs") end)

		if studcall then
	studpart.Surface.TopSurface = "Smooth"
	local studtex = Instance.new("Texture")
	studtex.Texture = studtex.assetId == "http://www.roblox.com/asset/?id=9818768"
	studtex.Face = "Top"
	local inletcall = pcall(function() has (v, "Inlets") end)

	if inletcall then
	studpart.Surface.BottomSurface = "Smooth"
	local studtex = Instance.new("Texture")
	studtex.Texture =  studtex.assetId == "http://www.roblox.com/asset/?id=65432522"
				studtex.Face = "Bottom"
				end
			end
		end
	end

Essentially what it does is grabs any part in the workspace that has studs or inlets, changes their surfaces to smooth, and adds a texture on top of the surface that had previously had studs on it.

It doesn’t seem to want to work, so I’m asking what is the correct way to know how to get parts with studs/inlets, so I can fix this.

That’s not really what pcall is for. Normally you would use it when there is a possibility the function you pass into it may error. If you already verified that you are looking at a Part then you shouldn’t need to use pcall.

To check if a part has a specific surface you can just do something like this:

if (studpart.TopSurface == Enum.SurfaceType.Studs) then
	-- whatever
end

Here are all the values of the SurfaceType enum:

3 Likes

So I basically just wrote out all that and waited a whole week just for someone to break it down to the simplest thing ever? lol (Because people were also confused and couldn’t figure out how to find studs either)