Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Script doesnt load the decal from its ID for some reason???

My script is supposed to show a decal by its ID but for some weird reason most of the times it doesnt work. The only time it works is when im putting in the '1234567' and it uploads some off-topic image. Here is the code:

local textBox = script.Parent
local Image = script.Parent.Parent.Image

textBox.FocusLost:Connect(function()
	Image.Image = 'http://www.roblox.com/asset/?id=' ..textBox.text
end)

On the line five ive also wrote 'rbxassetid://' before but it doesnt change anything. Any idea of a fix to this?

Oh. Almost forgot. Here is the output for it

14:59:00.865 - Image "https://assetdelivery.roblox.com/v1/asset?id=904635292" failed to load in "Players.SrOgurman.PlayerGui.ScreenGui.Image.Image": Request failed

UPDATE Weirdly it only works with some 7 digits numbers

1 answer

This is because of Roblox's slow speed of matching ids correctly to their image, this can be solved by creating a Decal and putting in the texture and then getting the reformatted texture:

local function getImageID(decal)
    -- set decal 

    local Decal = Instance.new("Decal")
    Decal.Texture = "rbxassetid://" .. decal
    -- studio will auto update this

    local ImageID = Decal.Texture
    Decal:Destroy() -- remove unwanted decal

    return ImageID
end

-- usage: getImageID(000000)

2 comments

0

I am afraid that doesn't work either. I mean works just as the methods i used. Only works with '1234567'. :(

0

Not only with '1234567'. It works only with 7 digit numbers. How in the world that works???

This discussion is preserved as it was. New answers, comments, and votes are closed.