So I’m trying to change the texture of a decal like this:
for i,decal in pairs(Model:GetChildren()) do
if decal:IsA("Decal") then
decal.Texture = "rbxassetid://"..TextureID
end
end
But it doesn’t change its texture. I have looked at the decal and it applied the right texture but it just didn’t change its look. I’ve also tried it with “http://www.roblox.com/asset/?id=”…TextureID but this also didn’t change anything. But when I paste the id in their myself it works.
Hi! I tried to replicate something similar so I did the following:
I tagged the decal with a “Decal” Tag, then used CollectionService to call the objects. I think this is better as you can tag a lot of decals, and change specific ones with little code
The code (in ServerScriptService):
local CollectionService = game:GetService("CollectionService")
local TextureID = [MUST BE AN INTEGER]
for i,decal in pairs(CollectionService:GetTagged("Decal")) do
if decal then
print("Changing Decal!")
decal.Texture = "rbxassetid://"..TextureID
end
end
What if you have many decals?
Suppose you have 3 decals, if we did the following:
local CollectionService = game:GetService("CollectionService")
local TextureID = [MUST BE AN INTEGER]
for i,decal in pairs(CollectionService:GetTagged("Decal")) do
if tostring(decal) == "Decal1" then
print("Changing Decal!")
decal.Texture = "rbxassetid://"..TextureID
elseif tostring(decal) == "Decal2" then
print("Changing Decal!")
decal.Texture = "rbxassetid://"..TextureID
elseif tostring(decal) == "Decal3" then
print("Changing Decal!")
decal.Texture = "rbxassetid://"..TextureID
end
end
This can be very messy very quick, so instead we can pair by index:
local CollectionService = game:GetService("CollectionService")
local Textures = {
[Number for texture 1],
[Number for texture 2 (remove the brackets!)],
[Number for texture 3]
}
for i,decal in pairs(CollectionService:GetTagged("Decal")) do
if decal then
print("Changing Decal!")
decal.Texture = "rbxassetid://"..Textures[i]
end
end
I understand, I think the tagged method should still work as you can call tagged objects from ServerScriptService, and I think is an easier method than getting a model’s children and going through them. By tagging them, you know each decal you tag will be a decal so you can avoid doing decal:IsA"Decal"!
Interesting, so I will confirm that the issue is not with the specific piece of code sent over as I made a part with a decal and was able to change the decal with the given method. I don’t think you did anything wrong with the implementation of the textureID, have you tried publishing it to Roblox first, then checking within a Roblox game to see if it is a Studio bug perhaps?
Code I used:
local Texture = [MUST BE AN INTEGER]
local Model = workspace:WaitForChild("TestingDecal")
for i,decal in pairs(Model:GetChildren()) do
if decal:IsA("Decal") then
decal.Texture = "rbxassetid://"..Texture
end
end
Was there a solution to this? I’m having problems with the same thing too.
I’m attempting to use decals available in the marketplace store with no success. I’ve used the same precursors as you had in the original post, but I also tried "https://create.roblox.com/store/asset/"..id
None of these worked successfully with various IDs.
Unfortunate, I’ll keep my eyes peeled for other posts that crop up! Wonder if it’s something to do with a new feature added in recently made games, like for example how newer games have streamingenabled properties
Basically, it’s way more complicated than it should be. For some reason, decals and images are different things and you have to reference the image
Some people mention using HTTP requests and others mention removing one from the ID, getting game.MarketPlaceService:GetProductInfo(“Creator”) and checking to see if the creator is the same as the original ID. I quickly threw together some code for the latter:
local function findimage(creatorinfo, decalid)
local currentid = decalid
for i = 1,2000 do
currentid -= 1
local newinfo = game.MarketplaceService:GetProductInfo(currentid)["Creator"]
if newinfo["Id"] == creatorinfo["Id"] then
return currentid
end
end
end