How to add a texture(s) to all parts named something

i have an auto generated maze and I’m trying to add textures onto all parts from a script, in the maze script when i tell it to put textures on the generated parts it only puts it on half of them and i cant figure out how to do it so i decided to try and use "for i v in pairs loop to add the textures but i dont know how

shorter version, i just want to add textures to all parts named “wall” from a script

2 Likes

Here’s an example on how you would be able to do this:

local names = {
	Wall = 5106388908
}

for _,v: BasePart in ipairs(workspace:GetDescendants()) do
	if v:IsA("BasePart") and names[v.Name] then
		for _,e in ipairs(Enum.NormalId:GetEnumItems()) do
			local texture = Instance.new("Texture")
			texture.Texture = "rbxassetid://" .. names[v.Name]
			texture.Parent = v
			texture.Face = e
		end
	end
end

This loops through the workspace, check’s if the name can be found in names, if found: it loops through all the available NormalID types (for the Texture’s face).

Basically, it adds a texture to every single side, so you don’t have to worry about a texture in just a single side of the part.

2 Likes

what you mean a half? did wedge change?
Because some shapes like Wedge can’t be change by just telling to change all parts.
"but you can if you rename wedge in to a part or Part "

idk if this works for you but can you share a video or something?

for _, v in pairs(game.Workspace:GetDescendants()) do
 if v:IsA("BasePart") then
   if v.Name == "Wall" then
    local Texture = Instance.new("Texture")
    Texture.Parent = v
    Texture.texture = "rbxassetid://" .. "TEXTURE_ID_HERE"
   end
 end
task.Wait()
end

hey i already figured it out i just needed to add 5 lines of code lol but i tested this and it works so thatnk you for youre time!