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

When I set the image of an ImageLabel it doesn't show?

So I'm trying to make a round based game with images for every single minigame. The issue is, when I try to set the image of the ImageLabel, it doesn't show!

Here's the script I tried:

local ids = {
	397558836,
	32348996,
	477764158
}

local chosen = math.random(1, #ids)

script.Parent.Image = 'rbxassetid://'..tostring(ids[chosen])

The problem is that I'm not getting any error message. The Image just won't show. If I check the properties of the ImageLabel, it show that the image is 'rbxassetid://chosenid'.

I'm very confused...

4 comments

0

For the image to be able to load, you need an image id. You can get this by pasting the id into a decal object in studio or subtracting 1 until you get it.

0

They are actual image ids

0

Did you double check to make sure the images went through moderation first?

0

check my answer, that should answer your question

2 answers

✓ Accepted answer

The problem in here is that the IDs are not link to the images, they are links to the decals, therefore they do not load since you need the images.

To obtain the images, go to the id and subtract 1 from it (Example: 397558836 is actually 397558835)

I confirmed this worked for the first 2.

3 comments

0

what about the last?

0

same for the last, it's 477764157

0

oh thanks

I am not a very experienced scripter. But from what I've seen. When you load whatever game that uses local images and image label. The usual "rbxassetid://" is converted to "gameasset://". Since you can not use "gameasset://" to load your images, just do the following.

local ids = {
	"rbxassetid://397558836",
	"rbxassetid://32348996",
	"rbxassetid://477764158"
}

local chosen = math.random(1, #ids)

script.Parent.Image = ids[chosen]

When the game will start, it will convert the "rbxassetid://" to "gameasset://" and normally, will load the images.

I am not very good at explanation but I hope you understood.

2 comments

0

I do not think this is the problem.

0

also what you said about gameasset is incorrect.

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