Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to reload an asset?

Asked by
KarlXYZ 120
9 years ago

I'm sure this must be possible, I've got an ImageLabel and I want a character's thumbnail to appear on it. This is the current code:

local player = game.Players.LocalPlayer

local asset

if player.Name:sub(1,6) == "Guest " then
    asset = "http://www.roblox.com/thumbs/avatar.ashx?width=352&height=352&username=ROBLOX"
else
    asset = "http://www.roblox.com/thumbs/avatar.ashx?width=352&height=352&username=" .. player.Name
end

game:GetService("ContentProvider"):Preload(asset)

script.Parent.Image = asset

The code above works perfectly, but what if a player changes their character's appearance? How would I reload the thumbnail asset when they respawn so the thumbnail reflects the character's new appearance?

If I reset and check the GUI, I find that the thumbnail hasn't changed...

1 answer

Log in to vote
0
Answered by 9 years ago

From experimenting with it, my impression is that Roblox automatically caches anything you send a request for via Preload. Since the API has no functions like "PreloadAgain" or "ClearCache", I believe you have no way to get an updated version.

Ad

Answer this question