Custom Stud Script refuses to work, I have no idea whats wrong

I created a script that takes any Parts in the workspace with studs and inlets, and makes their material ‘SmoothPlastic’ with Studs and Inlets textures on them, however when I test the script, it doesn’t seem to work. Any help with it will be appreciated.

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.Material = "SmoothPlastic"
	local studtex = Instance.new("Texture")
	studtex.Texture = ("http://www.roblox.com/asset/?id=9818768")
	studtex.Face = "Top"
	local inletcall = pcall(function() has (v, "Inlets") end))
	
	if inletcall then
	studpart.Material = "SmoothPlastic"
	local studtex = Instance.new("Texture")
	studtex.Texture = ("http://www.roblox.com/asset/?id=65432522")
	studtex.Face = "Bottom"
	end
end

did you parent the texture to the part

Aren’t materials Enums, or is there something I am not getting?

Edit: Nevermind, I didn’t know you could use strings for materials.

I don’t really remember there being an enum or enum2 for materials

I’ll try this, but someone just brought up that there may be Enums for materials

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.Material = "SmoothPlastic"
	local studtex = Instance.new("Texture")
	studtex.Texture = ("http://www.roblox.com/asset/?id=9818768")
	studtex.Face = "Top"
	local inletcall = pcall(function() has (v, "Inlets") end))
	
	if inletcall then
	studpart.Material = Enum.Material.SmoothPlastic
	local studtex = Instance.new("Texture")
	studtex.Texture = ("http://www.roblox.com/asset/?id=65432522")
	studtex.Face = "Bottom"
	end
end

you need to use Enum.Material not just “SmoothPlastic”

Forgot to say this is a serverscript in the workspace if that does any help

This didn’t seem to work, I am really confused as to what is causing the script to refuse to place the textures

oh I see now

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.Material = Enum.Material.SmoothPlastic
	local studtex = Instance.new("Texture")
	studtex.Texture = studtex.assetId = 9818768
	studtex.Face = "Top"
	local inletcall = pcall(function() has (v, "Inlets") end))
	
	if inletcall then
	studpart.Material = Enum.Material.SmoothPlastic
	local studtex = Instance.new("Texture")
	studtex.Texture =  studtex.assetId = http://www.roblox.com/asset/?id=65432522
	studtex.Face = "Bottom"
	end
end

I think this should work.

if I reply late probably cause i’m asleep

That also did not seem to work :sweat_smile: Although I did try 3 other things like adding the full asset link to the stud texture, and also adding quotations to them, but that didn’t seem to work either. Thank you for your help though.

I’ll probably just ask scriptinghelpers lol