How to use PreloadAsync properly?

This question isn’t specifically about what the title says but it’s the only way I could describe the situation. I have a menu screen that shows as soon as you enter my game, when you hover over the buttons they change color. Since they are ImageButtons I have to switch it to a whole other image. The first time you hover your mouse over the button the change in the image looks very choppy as if it still had to load, but after you do it the first time it is smooth.

For reference, I did use preload async on both the default image and the image that shows when the mouse is hovering.

Here is what I mean:
(EDIT: The gyazo did not capture the issue)

Here is how I preloaded the images (it’s a local script in ReplicatedFirst):

game:GetService("ContentProvider"):PreloadAsync(game.ReplicatedStorage.Animations:GetDescendants())

Is it that I am not loading them properly or is this some sort of unfixable issue?

3 Likes

PreloadAsync takes a table of Instances and automatically preloads any instances in the table and their descendants.

To preload ReplicatedStorage.Animations and it’s descendants, you would do this:

 game:GetService("ContentProvider"):PreloadAsync({game.ReplicatedStorage.Animations})
5 Likes

That is a valid point, the issue is that your solution is fundamentally the same as what I did. GetDescendants returns a table of the descendants, therefore the assets in question are still theoretically being loaded with extra steps.

I fixed the error, the script that was preloading was disabled :face_with_hand_over_mouth:

9 Likes