TextureID not working for some textures

Hey all,
I have a script that runs through all parts of a car and sets the texture id (to achieve a livery).
I was testing it out and for the textures that I have specified, none of them work and instead return a grey color.

The current code that I am using is:

local parts = script.Parent:GetChildren()

for i = 1,#parts do
	if parts[i].Name == "Color" or parts[i].Name == "Trunk" or parts[i].Name == "Hood" then
		if random == 1 then
			parts[i].TextureID = "rbxassetid://73737626"
		elseif random == 2 then
			parts[i].TextureID = "https://www.roblox.com/library/5139177423/HEAT"
		elseif random == 3 then
			parts[i].TextureID = "https://www.roblox.com/library/5139180460/K9"
		elseif random == 4 then
			parts[i].TextureID = "https://www.roblox.com/library/5139154759/SUVSMPD-Regular-Patrol"
		end
	end
end

Please disregard the poor efficiency in using the if statements.

None of the textures I have specified work, instead loading a grey texture as seen below:

My first thoughts were that it was something specifically wrong with each texture. I tried another one off of the decals front page which worked.

This clearly shows that the textures themselves aren’t working but when I tried manually adding them, it did work as seen below:

So I’m a little confused as to why that collection of ones aren’t working when they are inserted, yet other decals off of the front page do and the collection of ones work when manually set.

Thank you for any help that I receive.

1 Like

To start, make sure the desired parts you intend to texture aren’t modeled off deeper into the car hierarchy. The :GetChildren() method only looks through direct descendants, while :GetDescendants() looks through ALL descendants of the specified object.

What seems to be the problem is the texture itself. For random = 2, 3, & 4, you are not using asset id’s, rather you are using the library id. Put all of the textures into a random decal and then replace whatever is INSIDE the decal into its respective spot on the script. This is one possible error with your script.

I would also check if each parts[i] object is the correct object class in case you accidentally name a part/script “Color”, “Trunk”, or “Hood” Hopefully this helped!