0

# How do I check if a decal has loaded?

Loot_O 42
9 months ago

I've found a 4 year old scripting helpers post that says how to, but I have a problem.

Now, this is a part from the solution of the question. And when I went to the link, it says it's deprecated. I saw PreloadAsync is the replacement, but I am not sure how I would use it, so when you're making a response, please provide an example, because I am very confused about how to use it. I've also seen the example in the PreloadAsync page, but I am still confused. Anyways that's all!

2
TGazza 799
9 months ago

The PreloadAsync function loads multiple decals at once rather then the old Preload which in tern only loaded the decals 1 by 1

I've re-written the code from the PreloadAsync page from the page you specified, Hopefully its a little clearer on how to use the new Async preload function.

Note: the table below in the code isn't required to use PreloadAsync function its just a way to set a flag (true/false) when the decal has loaded or not you can use a simple table like:

local ContentProvider = game:GetService("ContentProvider")
local Decals = {
"rbxassetid://1234561",
"rbxassetid://1234562"
}

local function getStatus(contentId, status)
if(status == Enum.AssetFetchStatus.Success) then
end
end



Might be a better format:

local ContentProvider = game:GetService("ContentProvider")
local Decals = {
{
DecalID = "rbxassetid://1234561",
},
{
DecalID = "rbxassetid://1234565",
}
}
local DecTble = {}
for k,v in pairs(Decals) do
DecTble[k] = v.DecalID
end

local function getStatus(contentId, status,Table)
if(status == Enum.AssetFetchStatus.Success) then
end
end

for k,v in pairs(Decals) do
ContentProvider:PreloadAsync(DecTble, function(contentId, status) getStatus(contentId, status,v) end)
end

for k,v in pairs(Decals) do