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

How would I make random shirt generator for npc clones?

Asked by 4 years ago
Edited 4 years ago

I have a script that randomizes npc clothes but every time I want to add a shirt link in a list of clothes that the script picks from but I have to change the link every time to add it in. It is confusing. I get an error saying the request failed. Code: (All the links here are made to work which they do but I want to add more without taking so much time to change each link)

local BoyShirts = {"http://www.roblox.com/asset/?id=13997646","http://www.roblox.com/asset/?id=133708636","http://www.roblox.com/asset/?id=3222913587","http://www.roblox.com/asset/?id=65387140","http://www.roblox.com/asset/?id=575732308","http://www.roblox.com/asset/?id=3428011276","http://www.roblox.com/asset/?id=1616486271","http://www.roblox.com/asset/?id=1616526763","http://www.roblox.com/asset/?id=1119852208","http://www.roblox.com/asset/?id=398635080","http://www.roblox.com/asset/?id=98913038","http://www.roblox.com/asset/?id=1747307261","http://www.roblox.com/asset/?id=983506634"}

local Shirt = math.random(1,#BoyShirts)

clone.Shirt.ShirtTemplate = BoyShirts[Shirt]

1 answer

Log in to vote
0
Answered by 4 years ago

Your really close. Im also going to help your practice social distancing with some code indents!

local BoyShirts = { -- Our array of shirtids
    13997646,
    133708636,
    3222913587, -- This one
    65387140,
    575732308,
    3428011276,
    1616486271,
    1616526763,
    1119852208,
    398635080,
    98913038,
    1747307261,
    983506634
}

local getShirt = function()
    return BoysShirts[ math.random(1,#BoysShirts) ] -- In a nutshell this does Table[3] which will be ^^^^
end

for _,p in next,game.Players:GetPlayers() do -- Sorting through all players in the game
    p.Character.Shirt.ShirtTemplate = "rbxassetid://"..getShirt() -- Changing their original Shirt rather than cloning and swapping.
end
Ad

Answer this question