ImageLabel flickering on mobile devices

I have a script that changes ImageLabels per specified amount of time. It helps an object look “animated”.

local Mainimage = script.Parent.ImageLabel

local imageIds = {
	"rbxassetid://15749106215",
	"rbxassetid://15749107556",
	"rbxassetid://15749108703",
	"rbxassetid://15749110029",
	"rbxassetid://15749111322",
	"rbxassetid://15749112560",
	"rbxassetid://15749113597",
	"rbxassetid://15749115044",
	"rbxassetid://15749116243",
	"rbxassetid://15749117520",
	"rbxassetid://15749118634",
	"rbxassetid://15749119967",
	"rbxassetid://15749121269",
	"rbxassetid://15749124939",
	"rbxassetid://15749126342",
	"rbxassetid://15749127761",
	"rbxassetid://15749129257",
	"rbxassetid://15749130502"
}

while true do
	for _, imageId in ipairs(imageIds) do
		Mainimage.Image = imageId
		wait(0.1)
	end
end

That was the original code, so I’ve added a preloading asset function:

local Mainimage = script.Parent.ImageLabel

local imageIds = {
    "rbxassetid://15749106215",
    "rbxassetid://15749107556",
    "rbxassetid://15749108703",
    "rbxassetid://15749110029",
    "rbxassetid://15749111322",
    "rbxassetid://15749112560",
    "rbxassetid://15749113597",
    "rbxassetid://15749115044",
    "rbxassetid://15749116243",
    "rbxassetid://15749117520",
    "rbxassetid://15749118634",
    "rbxassetid://15749119967",
    "rbxassetid://15749121269",
    "rbxassetid://15749124939",
    "rbxassetid://15749126342",
    "rbxassetid://15749127761",
    "rbxassetid://15749129257",
    "rbxassetid://15749130502"
}

-- Preload images
local preloadedImages = {}
for _, imageId in ipairs(imageIds) do
    local preloadImage = Instance.new("ImageLabel")
    preloadImage.Image = imageId
    preloadImage.Visible = false
    preloadImage.Parent = script.Parent
    table.insert(preloadedImages, preloadImage)
end

local currentIndex = 1

while true do
    -- Display preloaded image
    Mainimage.Image = preloadedImages[currentIndex].Image
    Mainimage.Visible = true
    
    -- Increment index or reset to 1 if end of list is reached
    currentIndex = currentIndex + 1
    if currentIndex > #preloadedImages then
        currentIndex = 1
    end
    
    wait(0.1)
end

But that did not solve the issue. It’s still flickering and if it was a pre-loading issue, they should have worked after they have been already displayed once, no?

This script runs constantly without stopping, it’s to animate a 2D world object (nextbot).

It’s only happening on mobile devices and not on PC nor Studio’s mobile device player.

1 Like

Images can be like that, but it’s most likely a loading issue. You could try different methods such as preloading and use separate image labels.

Though I would recommend testing in Roblox, images usually load faster in Roblox compared to studio;

2 Likes

You should use ContentProvider:PreloadAsync to load stuff. The method above probably doesn’t work ideally.

It’s also very possible that Roblox just doesn’t handle the image switching very well. I couldn’t say without seeing it though. I would see if it happens outside of studio also.

ive had this issue with buttons that change icons
the closest ive gotten to fixing it is to make offscreen imagelabels and imagebuttons and use PreloadAsync on those

What are your fps on a PC compared to mobile? If a mobile device uses half the fps then maybe it’s the cause of the flickering.

Have you thought of using a ParticleEmitter flipbook instead?

Only happens on mobile as I mentioned. I don’t think preload would work because as I said, the flickering should only happen once, then the images should work normally right? As this is a nextbot similar to those in Evade, it follows you around and is animated, forever.

1 Like

Both run on 60 fps. Issue only persists on mobile devices, even at max graphics.

visual representation of pc/mobile differences (ignore the bad screen recorder for mobile, it got compressed so bad)


(and it never happens on studio, these 2 recordings are not from studio)

1 Like

Yeah.

From the video, it does look like there is a loading delay. It’s possible that the images are being taken out of ram (and then need to be loaded back in) because mobile devices have pretty limited memory, but I’m not familiar with Roblox’s memory management.

I’m not sure what the ideal way to fix this is. Using two images labels would solve it, but shouldn’t need to be done. Perhaps you can find some code that does something similar and see what they did.

1 Like