Need help changing decals with a script

hello I’m working on a map edit
that has like 1000 of the same decal

I’m wondering if anyone can create a script that will

set
image
the texure id to another one

every model in the workspace i want to be effected

1 Like

What do you want the trigger of the script to be? and for what purpose? I would like more info please so I can know what you’re exactly looking for.

1 Like

well i just need it to change every single texture id with another di
something like if texture id is this then change it to that

I mean I guess.


while true do
wait()
if Decal.Texture == “(Id here)” then
Decal.Texture = "(Id here)
end
end


I assume you know what to do with the rest of the script.

unknown global decal

while true do
	
	wait(1)
	if Decal.Texture == 23310732 then
		Decal.Texture = "(Id here)"
	end
end

Try this

for i, v in pairs(game.Workspace:GetDescendants()) do
   if v:IsA("Decal") then
      if v.Texture == "rbxassetid://23310732" then -- Old ID here
         v.Texture = "rbxassetid://000000" -- New ID here
      end
   end
end
1 Like

:man_facepalming: for “(Id here)” change it to exactly how the decal code is, for example, like in the picture you have it says “rbxassetid://23310732” so then the code would be.


while true do
wait(1)
if Decal.Texture == “rbxassetid://23310732” then
Decal.Texture = “(Id here)” — replace “(Id here)” with any Id exactly like I said for the top
end
end


1 Like

Is there a reason why you can’t just manually edit it? If you go in the explorer and highlight all of the decals, you can just enter the ID and it will change all of them.

No, the error @mikebramble591 was reporting had to do with Decal in lines 4 and 5 not being defined.
Try @VeriBaesix’s suggestion instead.

On second thought, what if the decal had another parent (like a part?)

1 Like

He would then manually select 1000 decals without accidentally deselecting them all instead of writing a 7 line code

1 Like

If you search “Decal” all of them will pop up at once and you can mass select them. I don’t know how that is less efficient then the game constantly iterating through thousands of decals every time the server loads up?

He would use the command bar (which affects the studio, not the game servers) so the script would only need to be ran once.

(assuming that he will use the command bar)

The parents of all the decals still show up, making it a pain to deselect all.
And of course, what if he needed to change everything ingame too?

1 Like

Again, it’s search “Decal” and highlight. This will take at most 10-20 seconds to do and then it’s a matter of entering the new ID.

Not really,


As you can see, the entire directory would show up.

Also, this quarreling isn’t really helping us get to a final product.

There’s a key bind that lets you select more than one, you don’t have to click each of them one by one. I don’t remember it off the top of my head but I’ve used it before.

Try this (untested):
This should seek out every decal in the game.

function changeDecalTextures(obj)
    if #obj:GetChildren() > 0 then
        for i,v in obj:GetChildren() do
            wait()
            if v:IsA('Decal') then
                v.Texture = 'something'
            else
                changeDecalTextures(v)
            end
        end
    end
end

changeDecalTextures(game)

Its Cmd/Ctrl + click to select more than one at once