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

How can I make a random shirt generator using math.random?

Asked by
Rukreep 15
3 years ago

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.

0
are you sure clothing.ShirtTemplate equals nil to begin with? Hqsuperlabgames 41 — 3y

Answer this question