When adding an image to an ImageLabel from a LocalScript, the image doesn’t load. When adding the same asset Id to an image label in the Studio editor it works fine. What could be the reasons for this?
This is the script: (LocalScript)
script.Parent.Image = 'rbxassetid://18209607659'
The image appears completely empty, replacing the template image.
This should work fine… Are you sure the asset uri is correct? If you’re getting the asset id from the Create Dashboard, make sure you’re copying the Image asset id, not the Decal asset id. You can ensure the asset uri is correct by copying the id, pasting it into an ImageLabel’s Image property, then copying the string that the Image property gets formatted to into the script that is setting it.
You must convert the Decal to a Image first, have you tried this?
filteredText = target
if tonumber(filteredText) then
local imageinfo = game:GetService("MarketplaceService"):GetProductInfo(filteredText, Enum.InfoType.Asset)
if not imageinfo then return end
if imageinfo.AssetTypeId == 10 or imageinfo.AssetTypeId == 13 then
local success, obj = pcall(function()
game:GetService("InsertService"):LoadAsset(filteredText)
end)
if success then
obj = game:GetService("InsertService"):LoadAsset(filteredText)
if obj:FindFirstChildWhichIsA("Decal") then
filteredText = obj:FindFirstChildWhichIsA("Decal").Texture
--warn("BLAH2")
end
end
else
if imageinfo.AssetTypeId == 1 then
filteredText = "rbxthumb://type=Asset&w=768&h=432&id=" .. filteredText
else
--[[warn(imageinfo.AssetTypeId)]] return
end
end
--filteredText = "rbxthumb://type=Asset&w=768&h=432&id=" .. tonumber(filteredText)
else
local decaltable = require(script.Parent.ImageList)
local found = false
for _, decal in ipairs(decaltable) do
--print("Name: "..decal[1]..", ID: "..decal[2])
if target and string.lower(decal[1]) == string.lower(target) then
found = true
if typeof(decal[2]) == "number" then
filteredText = "rbxthumb://type=Asset&w=768&h=432&id=" .. decal[2]
else
filteredText = decal[2]
end
end
end
if found == false and target then
local success = pcall(function()
game.Players:GetUserIdFromNameAsync(filteredText)
end)
if success then
filteredText = game.Players:GetUserThumbnailAsync(game.Players:GetUserIdFromNameAsync(filteredText), Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)
else
--warn(success .. game.Players:GetUserIdFromNameAsync(filteredText))
return
end
end
end
When you get the Image ID, you can use it over and over again. Also includes support for players.