My idea is : Everytime an NPC spawns, it creates a piece of clothing that contains a random ID from math.random(). I want to make such, but i can't really do it. I want it so that if the Id is nil then repeat the piece of code until there's a valid id.
Here's my non functional code.
local clothing = script.Parent while wait() do if clothing.ShirtTemplate == nil then clothing.ShirtTemplate = "rbxassetid://".. math.random(0,99999999) repeat until clothing.ShirtTemplate ~= nil else print("success") end end
As mentioned, it doesn't work. it just prints success.