Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago
Edited 4 years ago

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

Log in to vote
0
Answered by
cegberry 432 Moderation Voter
4 years ago
Edited 4 years ago

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)
0
I am afraid that doesn't work either. I mean works just as the methods i used. Only works with '1234567'. :( SrOgurman 2 — 4y
0
Not only with '1234567'. It works only with 7 digit numbers. How in the world that works??? SrOgurman 2 — 4y
Ad

Answer this question