So i have this line of code, it works fine but the only part i have a question about is newTemplate.Image
Im trying to set the image to the link i put behind it, however when i playtest it it just stays blank?
Is this because of my code or because of the link i put in? Help would be appreciated!
for Index, Value in ipairs(Folder:GetDescendants()) do
print(Value.Name)
table.insert(Table, Value.Name)
if Value.Name == "Garfield" then
local newTemplate = template:Clone()
newTemplate.Name = "Garfield"
newTemplate.Parent = scrollframe
newTemplate.Image = "https://create.roblox.com/marketplace/asset/11882416957/Garfield"
newTemplate.Visible = true
There is another way that involves subtracting 1 from the decal ID until you reach the image, but this is super inefficient and will just end being more code. The shortest way to do this is paste the decal id into an image property, then copy the new id it creates, but that’s also super slow. If you easily wanna just do it through scripts then do this:
local InsertService = game:GetService("InsertService")
local MarketplaceService = game:GetService("MarketplaceService")
function getImageIdFromDecal(decalId: number)
local assetInfo = MarketplaceService:GetProductInfo(decalId, Enum.InfoType.Asset)
assert(assetInfo.IsPublicDomain)
assert(assetInfo.AssetTypeId == Enum.AssetType.Decal.Value)
local decal = InsertService:LoadAsset(decalId):FindFirstChildWhichIsA("Decal")
return decal.Texture
end
print(getImageIdFromDecal(3339338289))
Keep in mind the above is a function, therefore you can use it multiple times with different ID’s.
Your decal is probably not public, here is a fix for this:
local InsertService = game:GetService("InsertService")
local MarketplaceService = game:GetService("MarketplaceService")
function getImageIdFromDecal(decalId: number)
local assetInfo = MarketplaceService:GetProductInfo(decalId, Enum.InfoType.Asset)
assert(assetInfo.AssetTypeId == Enum.AssetType.Decal.Value)
local decal = InsertService:LoadAsset(decalId):FindFirstChildWhichIsA("Decal")
return decal.Texture
end
print(getImageIdFromDecal(3339338289))