How do I make it so the piggy skin is randomized in a folder,
function module.DressPiggy(piggy) local character = game.ServerStorage.Piggy:Clone() character.Name = piggy.Name piggy.Character = character character.Parent = workspace
end
For example like this before,
function module.ChoosePiggy(players) local RandomObj = Random.new() local chosenPiggy = players[RandomObj:NextInteger(1,#players)] return chosenPiggy
My main part in my example is the local chosenPiggy = players[randomobj:NextInteger(1#players)]
Would it just be local dressPiggy = game.ServerStorage.#PiggySkins[RandomObj:NextInteger(1,#PiggySkins)]
Please correct me this is essential.
You can use math.random(min, max)
to get a random number on a interval, and then select the piggy by the table index
function module.ChoosePiggy(players) local chosenPiggy = players[math.random(1,#players)] -- Here we will get a number between 1 and the number of players return chosenPiggy end
In this case, chosenPiggy
will be a player
If this answers your question, pleace mark the answer as accepted