Hi, I am trying to have a function choose a random character that the player will play from a table. Instead of getting the name, I get nil. Here is my code:
local availableCharacters = {}
function module.MoveAvailableCharacters()
for i, v in pairs(game.ReplicatedStorage.AvailableCharacters:GetChildren()) do
table.insert(availableCharacters, v.Name)
end
end
function module.ChooseCharacterTest()
for i, v in pairs(game.Players:GetPlayers()) do
local randomCharacter = math.random(1, #availableCharacters)
local chosenCharacter = table.find(availableCharacters, randomCharacter)
print(chosenCharacter)
v:FindFirstChild("Character").Value = tostring(chosenCharacter)
table.remove(availableCharacters, randomCharacter)
end
end