Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Is there a way to load a random decal?

So basically I've been trying to make a button that loads a random decal. Problem is, decals share the same IDs as models, places, etc...

I've tried doing a script, which keeps randomly choosing asset IDs until it finds a decal but it's not working for some reason.

 local ID = math.random(1, 73737627)
 local MarketplaceService = game:GetService("MarketplaceService")
 local productInfo = MarketplaceService:GetProductInfo(ID, Enum.InfoType.Product)          
 if productInfo.AssetTypeId == 7 then
 print("Success!")

Could somebody either help me with it or show me an alternate way? Thanks.

1 comment

0

Whiz's seems good, this one has too many flaws becuase you will also have to constantly update the random number as well

1 answer

✓ Accepted answer

You can create a table of the decals you want and select a random one from there:

local decals = script.Parent.Decals:GetChildren()
local ID = decals[math.random(1, #decals)]

ID will be a completely random decal that has been chosen from the table. In order to make it work, every ID would have to be an IntValue.

This discussion is preserved as it was. New answers, comments, and votes are closed.