TopStud and BottomStud texture spam in games!

I have noticed many people experience issues with a TopStud and BottomStud texture getting thrown into their game on random items and it starts to annoy many. I have made a script to help you all with it!

You can either copy paste this or type it yourself! Please include credit in the script.

local Players = game:GetService("Players")

-- Function to remove textures
local function removeTextures(player)
	for _, part in ipairs(workspace:GetDescendants()) do
		if part:IsA("Texture") and (part.Name == "BottomStud" or part.Name == "TopStud") then
			part:Remove()
		end
	end
end

-- Connect function to player added event
Players.PlayerAdded:Connect(removeTextures)

Please put this script in serverscriptservice!
Happy Developing!

5 Likes

Why ipairs? It’s prolly cool but it seems a bit unnecessary to me (heard it uses more data since it sorts stuff in the right order)…

Are the things people learn from community resources posts supposed to be “copyrighted”? And what if someone creates a similar script or the exact same script without ever seeing this tutorial? I’m not saying to remove this, just providing some thoughts.

Sorry if this comes off as rude, I’m not tryna make it come off that way.

2 Likes

ipairs is not any less performant than pairs - the difference is negligible although ipairs is slightly faster (again, negligible difference though). In this case, order doesn’t really matter, but it’s not hurting anything.

5 Likes

You actually don’t need a iterator function; just passing the table works.

1 Like

Yes, that is true, but I don’t really like it? Well I’m really used to using ipairs and pairs… From what I have tested, ipairs is slightly faster than using nothing. I personally will keep using an iterator (unless I am dealing with a shared table)
ipairs is made for arrays, so it makes sense why it’s the fastest iterator. GetDescendants, GetChildren and other functions return arrays so ipairs is the appropriate iterator to use

local IteratorFunction = function(Table)
	local i = 0
	
	return function()
		local v = Table[i + 1]
		local l = #Table - i
		i = v and i + 1 or nil

		return i, v, l
	end
end

for i, v, l in IteratorFunction({"a","b","c"}) do 
	print(i,v,l)
end

The idea of an iterator function is quite cool, and knowing this, having nothing is a bit odd

2 Likes