Attempt to index nil with "Clone"

Local script won’t clone random starter character into a starter player

local folder = repStorage:WaitForChild("StarterRandom")
local randChar = folder:GetChildren()
local randChar = {folder.StarterCharacter1,folder.StarterCharacter2, folder.StarterCharacter3, folder.StarterCharacter4 }

local charPicked = folder:FindFirstChild(randChar[math.random(1,4)]):Clone()
charPicked.Parent = game:GetService("StarterPlayer")
charPicked.Name = "StarterCharacter"
1 Like

this is because the variable randChar is already getting the children of the folder. (also you got the children twice). Remove the 2nd randChar as you already got the children and both are the same. then use math.random to select a child out of randChar instead of trying to find it again in the folder.

local folder = repStorage:WaitForChild("StarterRandom")
local randChar = folder:GetChildren()

local charPicked = randChar[math.random(1,4)]:Clone()
charPicked.Parent = game:GetService("StarterPlayer")
charPicked.Name = "StarterCharacter"
2 Likes