Image does not load, even using ContentProvider:PreloadAsync()

Hello!
I am creating a status effects system for my game, and I am using images for them.
Each one lasts 5 seconds and is the destroyed.
It all works fine, except the image itself doesn’t load when the item is cloned.

local frame = script:WaitForChild("EffectFrame")
local display = script.Parent:WaitForChild("Holder")

local powerIcons = {
	[1] = "http://www.roblox.com/asset/?id=ID_HERE",
	[2] = "http://www.roblox.com/asset/?id=ID_HERE",
	[3] = "http://www.roblox.com/asset/?id=ID_HERE",
	[4] = "http://www.roblox.com/asset/?id=ID_HERE",
	[5] = "http://www.roblox.com/asset/?id=ID_HERE",
	[6] = "http://www.roblox.com/asset/?id=ID_HERE",
	[7] = "http://www.roblox.com/asset/?id=ID_HERE",
	[8] = "http://www.roblox.com/asset/?id=ID_HERE",
	[9] = "http://www.roblox.com/asset/?id=ID_HERE",
	[10] = "http://www.roblox.com/asset/?id=ID_HERE",
	[11] = "http://www.roblox.com/asset/?id=ID_HERE",
	[12] = "http://www.roblox.com/asset/?id=ID_HERE"
}

local function addPowerEffect(power:string)
	print("Received")
	if powerIcons[power] then
		local clonedFrame = frame:Clone()
		local image = clonedFrame:WaitForChild("EffectImage")
		clonedFrame.Parent = display
		image.Image = powerIcons[power]
		task.wait(3)
        --code continues here, but it's irrelevant.
    end
end

I’ve tried using rbxassetid://, just inputting the id itself, and using ContentProvider:PreloadAsync().

I was just wondering if anyone knew why the image won’t load when I use the script, but works just fine when I don’t.

Any help is appreciated!

hi there im still confused

2 Likes

When you upload images to roblox it could take a while for it to be accepted. I tried to upload a full white square and it got rejected :skull:. Maybe yours havent been accepted?

1 Like

I uploaded it yesterday and the image works just fine when I put it in an ImageLabel without using a script. Not quite sure why it’s not working…

1 Like

Enter the game, and in the explorer check the image labels properties. If the image id is empty than it is a problem with your scripts. If the image id is in the properties then it’s a problem with studio. Let me know what you see.

1 Like

I made it print the Image property’s content after it was assigned to - the id is there.

I found that some images work fine, might be to do with resolution. I’ll have a look at that.

1 Like

Update: It’s not to do with resolution…

1 Like

I’m quite unsure on what’s going wrong. The last thing I can think of maybe the transparency of the decals or maybe they are overlapping (ZIndex). I’m really sorry.

1 Like

It’s no problem, thanks for your help. I’ll keep looking.

1 Like

it might be already mentioned but when you paste the id in roblox studio it gets replaced with the image id instead of the decal which doesnt happen with scripts (I am pretty sure) and a ImageLabel wont accept a decal id it only accepts a raw image id of the decal

this is atleast what I know and this is the only way

to avoid confusion: a Image of the decal is made when you upload a decal which have different ids and different purposes!

edit: tried it and yes ImageLabels dont accept decal ids, and should be used with its own Image Id

edit2: can you mark this as a solution if it worked?

I already tried using rbxassetid://, http://www.roblox.com/asset/?id=, and just the id number. Didn’t realise decals and images have different IDs, I’ll give it a go since it’s an ImageLabel.

Decals IDs are for decals and Image IDs are for "Image"Labels and plugin icons etc basically any gui related thing

Seems to have worked - I think I had some that were image IDs, and some that were decal IDs. Thanks a lot!

sorry lol it took a while to try out because I have a lot of images for this

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.