Randomized Character Selector

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    A randomized character selector
  2. What is the issue? Include screenshots / videos if possible!
    Im fairly new, I dont know how to make this
    image
    I have 8 models, and I want to select a random one of these 8 on start up
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I did, but im not understanding them
    After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
-- This is an example Lua code block

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

1 Like

If you can give any tips, that would be amazing.

local Characters = Characters:GetChildren()
local Character = Characters[math.random(#Characters)]

You should’ve looked at getting a random value in a table.

instead of randomizing character, why not randomizing accessories and other outlook things?

  1. Go to StarterPlayer in the Explorer and disable LoadCharacterAppearance
  2. Use HumanoidDescription to store your character appearances.
  3. Make a Script in ServerScriptService
--Simplified
--It supposes you know scripting

local HumDescriptions= {
    -- Here go all your HumanoidDescriptions.
}

Players.PlayerAdded:Connect(function(Player)
    Player.CharacterAdded:Connect(function(Character)
        local Humanoid = Character:WaitForChild("Humanoid")
        local RandomDescription = HumDescriptions[math.random(1,#HumDescriptions)]
        Humanoid:ApplyDescription(RandomDescription)
    end)
end)
1 Like

no, since i have 4 ver of male with diff outfits and 4 ver of female with diff outfits

i tried that before, but I didnt understand it

local Character = Characters[math.random(#Characters)]

What this does is simple, but we need to go reverse-mode. See, #Characters returns the amount of values a table has, and :GetChildren() returns a table with the children of the instance you gave it. math.random(#Characters) selects a random number between 1, and the amount of characters in the table. So for this case it would be a random number between 1 and 8. Characters[NUMBER] returns the value at which index it can be found, so for example in the following table:

local t = {"I", "am", "probably", "helpful"}

running this line below would output “probably”

print(t[3]) --> probably

Don’t be afraid to ask questions.

thats also cool… will look into using this kind of method to make other types of systems. Thank you!

1 Like

And to get a random value:

local t = {"this","is","amazing"}

print(t[math.random(1,#t)])

Usually the 1 is pretty useless in my opinion

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.