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

Is there a way to load a random decal?

Asked by 5 years ago
Edited 5 years ago

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.

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

1 answer

Log in to vote
1
Answered by 5 years ago

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.

Ad

Answer this question