How do i preload Gui images and imagebuttons?

How do i preload Images?
i’ve tried to preload them with PreloadAsync but it didn’t work

here is the code that i used


local Images = {}
local imagesleft = #Images

local ContentProvider = game:GetService("ContentProvider")

for _,v in pairs(script.Parent:GetDescendants()) do 
	if v:IsA("ImageLabel") or v:IsA("ImageButton") then 
		table.insert(Images,1,v.Image)
	end
end



ContentProvider:PreloadAsync(Images, function()
	imagesleft = imagesleft - 1 -- keeping count if you want to add some accuracy to a loading bar or something
	print(imagesleft)
end)

any help would be appreciated

PreloadAsync doesn’t work in studio, have you tried it in-game?

Ah i see, i’ll see if it works or not

1 Like