Hello, a few weeks ago I got stuck on my code, the code only works if you put an id, except if you add 2 or more id the code when the npc appears becomes null..
shirts = { 1118202405, 1537761670, 1442388484, 4413177915, 1471488077, 751482380, 2403967461 } local randomshirt = math.random(7,#shirts) local clothing = script.Parent.Clothing clothing.ShirtTemplate = "rbxassetid://"..shirts[randomshirt]
The only problem that I can see is that you're using math.random
incorrectly (at least in this use case). math.random
has two arguments; the minimum value and the maximum value. In this case you'd want the minimum value to be 1, not 7.
I'd also suggest setting the randomseed
to get more random values. The most convenient way to truly randomize the seed is to just set it to tick()
, which is a function that returns the time passed in Roblox's servers.
math.randomseed(tick()) shirts = { 1118202405, 1537761670, 1442388484, 4413177915, 1471488077, 751482380, 2403967461 } local randomshirt = math.random(1,#shirts) local clothing = script.Parent.Clothing clothing.ShirtTemplate = "rbxassetid://"..shirts[randomshirt]
Same problem.
I test with 3 option.
https://i.gyazo.com/02a3a7d41f0006b56c013b447278ede8.gif
In video :
https://i.gyazo.com/668a0c4e387caf17ebea340dec02cdf6.mp4
but if I enter it myself by pressing "enter", it works.