I am trying to make a script that creates a folder who's name is the player's name. But it keeps giving me this error: "Attempt to index upvalue 'LocalPlayerName' (a nil value)" Is there a solution for it?
function GetPlayerName(player) LocalPlayerName = player end game.Players.PlayerAdded:Connect(GetPlayerName) function MakePlayerFolder() local folder = Instance.new("Folder") folder.Name = LocalPlayerName.Name folder.Parent = game.Workspace.PlayerBuilds end MakePlayerFolder()
function MakePlayerFolder(player) local folder = Instance.new("Folder") folder.Name = player.Name folder.Parent = workspace.PlayerBuilds end -- in the function above we have the 'player' parameter which allows us to get the player's name. game.Players.PlayerAdded:Connect(MakePlayerFolder) -- we call the function inside of the PlayerAdded event which will automatically send its 'player' argument to the function.