Animated image flashing alot for some reason


the script

-- 🤨

local IDs = 
	{	"rbxassetid://118872947275117", -- 00
		"rbxassetid://119532748903884", -- 01
		"rbxassetid://83255127641106", -- 02
		"rbxassetid://87761251502532", -- 03
		"rbxassetid://111391697536215", -- 04
		"rbxassetid://95141079794457", -- 05
		"rbxassetid://94849466604500", -- 06
		"rbxassetid://70730907430474",-- 07
		"rbxassetid://119149148085678"} --08

while true do
	for i,v in ipairs(IDs) do
		task.wait(0.05)
		script.Parent.Image = v
		task.wait(0.05)
	end
end

Replication issues.
Change script context to be client and it should be a lot smoother and stop glitching.

also (more optimized):

--!strict
--!optimize 2
-- 🤨
-- !evil (jk this one does nothing)
local IDs:{string} = {
		"rbxassetid://118872947275117", -- 00
		"rbxassetid://119532748903884", -- 01
		"rbxassetid://83255127641106", -- 02
		"rbxassetid://87761251502532", -- 03
		"rbxassetid://111391697536215", -- 04
		"rbxassetid://95141079794457", -- 05
		"rbxassetid://94849466604500", -- 06
		"rbxassetid://70730907430474",-- 07
		"rbxassetid://119149148085678"--08
	} 
local Image:ImageLabel = script.Parent
while true do
	for i,v in IDs do
		Image.Image = v
		task.wait(0.05)
	end
end

oh boy i wonder how to fix this: the humble client context (seriously two of my scripting problems have been solved by just changing the context)
also im a scripting noob what does !strict and !optimize 2 supposed to do

they do nothing the error was in the script.Parent.Image = v the fix script.Parent.Image.Image = v

ok i feel like a mad man its still flickering and i have no clue what madox is on about

looking at the image label while playtesting shows that isloaded is flickering on and off, is there someway to cache these images so it should always be on?

this 2 are flags to tell specific instructions to bytecode compiler.
–!optimize 2 in a very short form “optimizes” your code by inlining some things and localizing variables

basically it does:

local workspace = workspace

Internally as since local variables is more optimized.

I have also added line:

local Image:ImageLabel = script.Parent

So you would have a dirrect referance to instance (since indexing consumes perfomance)

–!strict (typecheck) makes your script editor show advanced linting, forcing you to write optimized code.

https://www.youtube.com/watch?v=RgHDILkdBgg (i made a video about typechecking you can check it out if you want)

Hm are you sure that you are using surface gui?
Decals for example are costly to apply unlike ImageLabel.
It could be that some images have been moderated/refusing to load.

You can try making multiple ImageLabels and making others .Visible = false while making certain visible.

i can confirm that all of the images are not moderated, i checked myself

Idk

--!strict
--!optimize 2
-- 🤨
-- !evil (jk this one does nothing)
local IDs:{string} = {
	"rbxassetid://118872947275117", -- 00
	"rbxassetid://119532748903884", -- 01
	"rbxassetid://83255127641106", -- 02
	"rbxassetid://87761251502532", -- 03
	"rbxassetid://111391697536215", -- 04
	"rbxassetid://95141079794457", -- 05
	"rbxassetid://94849466604500", -- 06
	"rbxassetid://70730907430474",-- 07
	"rbxassetid://119149148085678"--08
} 

local FramesCount:number = #IDs
local Images:{ImageLabel} = table.create(FramesCount)::{ImageLabel}
local Root:Instance = script.Parent.Parent

for i,v in IDs do
	local a = Instance.new("ImageLabel")
	a.Visible = false
	a.Image = v
	table.insert(Images,a)
	a.Parent=Root
end



while true do
	for i,v in Images do
		if i==1 then Images[FramesCount].Visible = false;v.Visible=true;task.wait(0.5) continue end
		Images[i-1].Visible=false
		v.Visible = true
		task.wait(0.5)
	end
end

Maybe this works

local IDs = {
	"rbxassetid://118872947275117", 
	"rbxassetid://119532748903884", 
	"rbxassetid://83255127641106", 	
	"rbxassetid://87761251502532", 	
	"rbxassetid://111391697536215", 
	"rbxassetid://95141079794457", 	
	"rbxassetid://94849466604500", 	
	"rbxassetid://70730907430474",	
	"rbxassetid://119149148085678"	
} 

local Image:ImageLabel = script.Parent

while wait(0.5) do
	task.spawn(function()
		for i,v in ipairs(IDs) do
			Image.Image = v
			task.wait(0.05)
		end	
	end)	
end

Instead of changing the .Image value to the new image, you should make one unique imagelabel for each image, and just change the transparency of each. This is because when you change the .Image property its not guaranteed to be instant (cant remember exact source) however changing transparency appears to work better.

Additonally you can preload all of the images via ContentProvider: PreloadAsync() and only start animating once it has confirmed all image have fully loaded, which ensures it wont flicker when it first starts being animated.

As an alternative, you could try to mess around with an EditableImage instead, as these are meant to be able to change, but I would recommend first trying to use transparency instead.